void UpdateAI(const uint32 diff)
        {
            if (currentPhase == PHASE_NONE)
                return;

            if (SummonTimer <= diff)
            {
                if (currentPhase<5&&currentPhase >= 0)
                {
                   Creature* pNext = NULL;
                   switch (currentPhase)
                   {
                        case PHASE_FRENZIED_WORGEN: pNext = Unit::GetCreature((*me), instance ? instance->GetData64(DATA_MOB_FRENZIED_WORGEN) : 0); break;
                        case PHASE_RAVENOUS_FURLBORG: pNext = Unit::GetCreature((*me), instance ? instance->GetData64(DATA_MOB_RAVENOUS_FURBOLG) : 0); break;
                        case PHASE_MASSIVE_JORMUNGAR: pNext = Unit::GetCreature((*me), instance ? instance->GetData64(DATA_MOB_MASSIVE_JORMUNGAR) : 0); break;
                        case PHASE_FEROCIOUS_RHINO: pNext = Unit::GetCreature((*me), instance ? instance->GetData64(DATA_MOB_FEROCIOUS_RHINO) : 0); break;
                        case PHASE_GORTOK_PALEHOOF: pNext = Unit::GetCreature((*me), instance ? instance->GetData64(DATA_GORTOK_PALEHOOF) : 0); break;
                        default: break;
                   }

                   if (pNext)
                   {
                        pNext->RemoveAurasDueToSpell(SPELL_FREEZE);
                        pNext->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_IMMUNE_TO_PC);
                        pNext->SetStandState(UNIT_STAND_STATE_STAND);
                        pNext->SetInCombatWithZone();
                        pNext->Attack(pNext->SelectNearestTarget(100), true);

                   }
                   currentPhase = PHASE_NONE;
                }
            } else SummonTimer -= diff;
        }
		void OnSelectOption(Object* pObject, Player* pPlayer, uint32 Id, const char* EnteredCode)
		{
			switch(Id)
			{
				case 0: OnHello(pObject, pPlayer); break;
				case 1:
					{
						int32 i = -1;
						Creature* pPrisoner = TO_CREATURE(pObject);
						switch(pPrisoner->GetEntry())
						{
							case 20677: i = 0; break;
							case 20678: i = 1; break;
							case 20679: i = 2; break;
						}

						if(i == -1)
							return;

						QuestLogEntry* pQuest = pPlayer->GetQuestLogForEntry(10368);
						if(pQuest != NULL && pQuest->GetMobCount(i) < pQuest->GetQuest()->required_mobcount[i])
						{
							pQuest->SetMobCount(i, pQuest->GetMobCount(i) + 1);
							pQuest->SendUpdateAddKill(i);
							pQuest->UpdatePlayerFields();

							pPrisoner->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You've freed me! The winds speak to my people one again and grant us their strength. I thank you, stranger.");
							pPrisoner->Despawn(5000, 6 * 60 * 1000);
							pPrisoner->SetStandState(STANDSTATE_STAND);
						}
					}
					break;
			}
		}
Example #3
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;
}
    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 #5
0
bool FilledShimmeringVessel(uint32 i, Spell* pSpell) // Blood Elf ress. quest
{
    if(!pSpell->u_caster->IsPlayer())
        return true;

    Player* plr = TO_PLAYER(pSpell->u_caster);

    Creature* target = plr->GetMapMgr()->GetCreature(GET_LOWGUID_PART(plr->GetSelection()));
    if(target == NULL)
        return true;

    if(target->GetEntry() != 17768)
        return true;

    QuestLogEntry *qle = plr->GetQuestLogForEntry(9685);
    if(qle == NULL)
        return true;

    target->SetStandState(0);
    target->setDeathState(ALIVE);

    target->Despawn(30*1000, 1*60*1000);

    qle->SetMobCount(0, 1);
    qle->SendUpdateAddKill(0);
    qle->UpdatePlayerFields();

    return true;
}
Example #6
0
bool SpragglesCanteen(uint32 i, Spell* pSpell) // Quest: Lost!
{
  if(!pSpell->u_caster->IsPlayer())
    return true;

  Player *pPlayer = (Player*)pSpell->u_caster;
  
  Creature *target = pPlayer->GetMapMgr()->GetCreature( GET_LOWGUID_PART( pPlayer->GetSelection() ) );
  if(target == NULL)
    return true;

  if(target->GetEntry() != 9999)
    return true;

  QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(4492);
  if(qle == NULL)
    return true;

  target->SetStandState(0);
  target->setDeathState(ALIVE);

  target->Despawn(30*1000, 1*60*1000);

  qle->SetMobCount(0, 1);
  qle->SendUpdateAddKill(0);
  qle->UpdatePlayerFields();

  return true;
}
Example #7
0
    void SetRuffies(uint64 guid, bool bAttack, bool bReset)
    {
        Creature* pCreature = (Creature*)Unit::GetUnit(*m_creature, 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_UNK_9);
        }
        else
        {
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_9);

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

            pCreature->SetStandState(UNIT_STAND_STATE_STAND);

            if (bAttack)
            {
                if (Unit* pUnit = Unit::GetUnit(*m_creature, m_uiPlayerGUID))
                {
                    if (pUnit->isAlive())
                        pCreature->AI()->AttackStart(pUnit);
                }
            }
        }
    }
Example #8
0
bool TheSeersRelic(uint32 i, Spell* pSpell)
{
	if ( pSpell == NULL || pSpell->u_caster == NULL || !pSpell->u_caster->IsPlayer() )
		return true;

	Player *pPlayer = static_cast< Player* >( pSpell->u_caster );
	QuestLogEntry *pQuest = pPlayer->GetQuestLogForEntry( 9545 );
	if ( pQuest == NULL || pQuest->GetMobCount( 0 ) >= pQuest->GetQuest()->required_mobcount[0] )
		return true;

	Creature *pTarget = pPlayer->GetMapMgr()->GetCreature( GET_LOWGUID_PART( pPlayer->GetSelection() ) );
	if ( pTarget == NULL )
		return true;

	if ( pTarget->GetEntry() != 16852 )
		return true;

	pTarget->SetStandState( 0 );
	pTarget->setDeathState( ALIVE );
	pTarget->Despawn( 30 * 1000, 1 * 60 * 1000 );
  
	pQuest->SetMobCount( 0, 1 );
	pQuest->SendUpdateAddKill( 0 );
	pQuest->UpdatePlayerFields();

	return true;
}
Example #9
0
 bool EffectDummy(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Object* pTarget, ObjectGuid /*originalCasterGuid*/) override
 {
     Creature* pCreatureTarget = pTarget->ToCreature();
     pCreatureTarget->CastSpell(pCreatureTarget, SPELL_COMPLETE_IMMOLATION, true);
     pCreatureTarget->SetStandState(UNIT_STAND_STATE_DEAD);
     pCreatureTarget->ForcedDespawn(10000);
     return true;
 }
Example #10
0
            void HandleScript(SpellEffIndex /*eff*/)
            {
                Creature* target = GetHitCreature();
                if (!target)
                    return;

                target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE);
                target->SetStandState(UNIT_STAND_STATE_SUBMERGED);
            }
Example #11
0
bool SymbolOfLife(uint32 i, Spell* pSpell) // Alliance ress. quests
{
    if(!pSpell->u_caster->IsPlayer())
        return true;

    Player* plr = TO_PLAYER(pSpell->u_caster);
    Creature* target = plr->GetMapMgr()->GetCreature(GET_LOWGUID_PART(plr->GetSelection()));

    if(target == NULL)
        return true;

    const uint32 targets[] = {17542, 6177, 6172};
    const uint32 quests[] =  {9600,  1783, 1786};
    bool questOk = false;
    bool targetOk = false;

    for(int i = 0; i<3; i++)
    {
        if(target->GetEntry() == targets[i])
        {
            targetOk = true;

            break;
        }
    }

    if(!targetOk)
        return true;

    QuestLogEntry *qle;

    for(int i = 0; i<3; i++)
    {
        if(plr->GetQuestLogForEntry(quests[i]) != NULL)
        {
            qle = plr->GetQuestLogForEntry(quests[i]);
            questOk = true;

            break;
        }
    }

    if(!questOk)
        return true;

    target->SetStandState(0);
    target->setDeathState(ALIVE);

    target->Despawn(10*1000, 1*60*1000);

    qle->SetMobCount(0, 1);
    qle->SendUpdateAddKill(0);
    qle->UpdatePlayerFields();

    return true;
}
Example #12
0
        void UpdateAI(const uint32 diff)
        {
            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                Creature* suna = me->GetCreature(*me, sunaGUID);
                if (!suna)
                {
                    Reset();
                    return;
                }

                switch (eventId)
                {
                    case EVENT_SUNA_KNEEL_TALK:
                    {
                        suna->SetStandState(UNIT_STAND_STATE_KNEEL);
                        suna->AI()->Talk(1);
                        break;
                    }
                    case EVENT_SUNA_TALK:
                    {
                        suna->AI()->Talk(2);
                        break;
                    }
                    case EVENT_SUNA_TALK_2:
                    {
                        suna->AI()->Talk(3);
                        break;
                    }
                    case EVENT_SUNA_STAND:
                    {
                        suna->SetStandState(UNIT_STAND_STATE_STAND);
                        Reset();
                        break;
                    }
                    default:
                        break;
                }
            }
        }
Example #13
0
    void TurnToPathaleonsImage()
    {
        Creature* pArdonis = m_creature->GetMap()->GetCreature(m_ardonisGuid);
        Creature* pPathaleon = m_creature->GetMap()->GetCreature(m_pathaleonGuid);
        Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid);

        if (!pArdonis || !pPathaleon || !pPlayer)
            return;

        m_creature->SetFacingToObject(pPathaleon);
        pArdonis->SetFacingToObject(pPathaleon);

        // the boss is there kneel before him
        m_creature->SetStandState(UNIT_STAND_STATE_KNEEL);
        pArdonis->SetStandState(UNIT_STAND_STATE_KNEEL);
    }
        // Emote Ardonis and Pathaleon
        void Turn_to_Pathaleons_Image()
        {
            Creature* ardonis = ObjectAccessor::GetCreature(*me, ardonisGUID);
            Creature* pathaleon = ObjectAccessor::GetCreature(*me, pathaleonGUID);

            if (!ardonis || !pathaleon)
                return;

            // Turn Dawnforge
            me->SetFacingToObject(pathaleon);

            // Turn Ardonis
            ardonis->SetFacingToObject(pathaleon);

            //Set them to kneel
            me->SetStandState(UNIT_STAND_STATE_KNEEL);
            ardonis->SetStandState(UNIT_STAND_STATE_KNEEL);
        }
    void KillHostage(uint8 index)
    {
        if(!HostagesGUID[index])
            return;
        Creature *hostage = (Creature*)(instance->GetUnit(HostagesGUID[index]));
        if(!hostage)
            return;

        WorldLocation wLoc;
        hostage->GetPosition(wLoc);
        Creature *corpse = hostage->SummonCreature(HostageInfo[index].deadnpc, wLoc.coord_x, wLoc.coord_y, wLoc.coord_z, wLoc.orientation, TEMPSUMMON_MANUAL_DESPAWN, 0);
        if(corpse)
        {
            corpse->SetStandState(UNIT_STAND_STATE_DEAD);
            // TODO: add some burn effect
        }
        hostage->Kill(hostage, false);
        hostage->RemoveCorpse();
    }
Example #16
0
    bool OnDummyApply(const Aura* pAura, bool bApply) override
    {
        if (pAura->GetId() != SPELL_HEALING_SALVE_DUMMY || 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;
    }
Example #17
0
        // Emote Ardonis and Pathaleon
        void Turn_to_Pathaleons_Image()
        {
            Creature* ardonis = Unit::GetCreature(*me, ardonisGUID);
            Creature* pathaleon = Unit::GetCreature(*me, pathaleonGUID);
            Player* player = Unit::GetPlayer(*me, PlayerGUID);

            if (!ardonis || !pathaleon || !player)
                return;

            //Calculate the angle to Pathaleon
            angle_dawnforge = me->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY());
            angle_ardonis = ardonis->GetAngle(pathaleon->GetPositionX(), pathaleon->GetPositionY());

            //Turn Dawnforge and update
            me->SetOrientation(angle_dawnforge);
            me->SendUpdateToPlayer(player);
            //Turn Ardonis and update
            ardonis->SetOrientation(angle_ardonis);
            ardonis->SendUpdateToPlayer(player);

            //Set them to kneel
            me->SetStandState(UNIT_STAND_STATE_KNEEL);
            ardonis->SetStandState(UNIT_STAND_STATE_KNEEL);
        }
Example #18
0
void GameEventMgr::DoScript(uint32 event_id, uint32 sql_id, uint8 type, uint32 data1, uint32 data2, uint32 data3, char * say, uint32 mapid)
{
	MapMgr * mapmgr = sInstanceMgr.GetMapMgr( mapid );
	if( mapmgr == NULL )
		return;

	Creature *c;
	GameObject *go;
	if(type < GAMEOBJECT_CHANGE_STATE)
	{
		c = mapmgr->GetSqlIdCreature( sql_id );
		if( c == NULL ) return;
	}
	else
	{
		go = mapmgr->GetSqlIdGameObject( sql_id );
		if( go == NULL ) return;
	}

	// create backup for original values
	EventScript * es = new EventScript();
	es->sql_id = sql_id;
	es->mapid = mapid;
	es->type = type;
	es->data_1 = 0; // null them out first!
	es->data_2 = 0;
	es->data_3 = 0;

	if( c && strlen(say) )
	{
		c->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, say);
	}

	switch( type )
	{
		case CREATURE_CHANGE_SCRIPTED_CHANGE:
		{
			CALL_SCRIPT_EVENT(c, GameEventStart)(event_id);
		} break;
		case CREATURE_CHANGE_EMOTE:
		{
			// do not backup one-shoot emote
			c->Emote(EmoteType(data1));

			// backup emote state first
			es->data_2 = c->GetEmoteState();
			c->SetEmoteState(data2);

			// backup stand state
			es->data_3 = static_cast<uint32>(c->GetStandState());
			c->SetStandState(static_cast<uint8>(data3));
		} break;

		case CREATURE_CHANGE_DISPLAYID:
		{
			es->data_1 = c->GetDisplayId();
			c->SetDisplayId(data1);
			es->data_2 = c->GetNativeDisplayId();
			c->SetNativeDisplayId(data2);
			es->data_3 = c->GetMount();
			c->SetMount(data3);

			c->EventModelChange();
		} break;

		case CREATURE_CHANGE_WEAPON:
		{
			es->data_1 = c->GetEquippedItem(MELEE);
			es->data_2 = c->GetEquippedItem(OFFHAND);
			es->data_3 = c->GetEquippedItem(RANGED);
			c->SetEquippedItem(MELEE, data1);
			c->SetEquippedItem(OFFHAND, data2);
			c->SetEquippedItem(RANGED, data3);
		} break;

		case CREATURE_CHANGE_REACT:
		{
			es->data_1 = c->GetFaction();
			c->SetFaction(data1);
			es->data_2 = c->GetUInt32Value(UNIT_NPC_FLAGS);
			c->SetUInt32Value(UNIT_NPC_FLAGS, data2);
			es->data_3 = c->GetUInt32Value(UNIT_FIELD_FLAGS);
			c->SetUInt32Value(UNIT_FIELD_FLAGS, data3);
		} break;

		case CREATURE_CAST_SPELL_ON_EVENT_START:
		{
			SpellEntry * sp = dbcSpell.LookupEntryForced( data1 );
			if( sp == NULL )
				return;

			SpellCastTime * casttime = dbcSpellCastTime.LookupEntry(sp->CastingTimeIndex);
			Spell * spell = sSpellFactoryMgr.NewSpell(c, sp, false, NULL);

			SpellCastTargets t(0);

			// force self casting
			if( data2 )
			{
				t.m_unitTarget = c->GetGUID();
			}
			else
			{
				spell->GenerateTargets(&t);
				spell->m_targets = t;
			}

			if (objmgr.IsSpellDisabled(spell->GetProto()->Id) || spell->CanCast(false) != SPELL_CANCAST_OK || !spell->HasPower() || c->m_silenced || c->IsStunned() || c->IsFeared() )
			{
				delete spell;
				return;
			}

			if( casttime->CastTime > 0 )
				c->GetAIInterface()->StopMovement(casttime->CastTime);

			spell->prepare(&t);

		} break;

		case CREATURE_CAST_SPELL_ON_EVENT_STOP:
		{
			// this time just backup it, we will procez it on event end
			es->data_1 = data1;
			es->data_2 = data2;
		} break;

		case CREATURE_CHANGE_UPDATE_FIELD:
		{
			es->data_1 = data1;
			es->data_2 = c->GetUInt32Value(data1);
			c->SetUInt32Value(data1, data2);
		} break;

		case CREATURE_CHANGE_DESPAWN:
		{
			GameEventMap::iterator itr = CheckAndReturnEvent( event_id );
			if( itr == m_GameEventMap.end() )
				return;

			uint32 current_time = mktime(&g_localTime);
			// this is calculated in seconds and added 1 extra second as timer for spawn and despawn
			uint32 respawntime = itr->second->end_time - current_time + 1;
			// values here are in miliseconds
			c->Despawn(0, respawntime*1000);
			delete es;
			return;
		} break;

		case GAMEOBJECT_CHANGE_STATE:
		{
			es->data_1 = (uint32)go->GetState();
			go->SetState((uint8)data1);
		} break;
	}

	// insert event into storage
	GameEventScriptMap::iterator itr = m_GameEventScriptBackup.find(event_id);
	if( itr == m_GameEventScriptBackup.end() )
	{
		set< EventScript* > s;
		s.insert( es );
		m_GameEventScriptBackup.insert(make_pair(event_id, s));
	}
	else
	{
		itr->second.insert( es );
	}
}
Example #19
0
bool EffectAuraDummy_spell_aura_dummy_npc(const Aura* pAura, bool bApply)
{
    switch (pAura->GetId())
    {
        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_ENRAGE:
        {
            if (!bApply || pAura->GetTarget()->GetTypeId() != TYPEID_UNIT)
                return false;

            Creature* pTarget = (Creature*)pAura->GetTarget();

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

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

            return false;
        }
        case SPELL_SHROUD_OF_DEATH:
        case SPELL_SPIRIT_PARTICLES:
        {
            Creature* pCreature = (Creature*)pAura->GetTarget();

            if (!pCreature || (pCreature->GetEntry() != NPC_FRANCLORN_FORGEWRIGHT && pCreature->GetEntry() != NPC_GAERIYAN))
                return false;

            if (bApply)
                pCreature->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE;
            else
                pCreature->m_AuraFlags &= ~UNIT_AURAFLAG_ALIVE_INVISIBLE;

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

            Unit* pTarget = pAura->GetTarget();
            if (bApply && pTarget->GetTypeId() == TYPEID_UNIT)
                ((Creature*)pTarget)->UpdateEntry(NPC_ENCASED_ELECTROMENTAL);
            return true;
        }
    }

    return false;
}
Example #20
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->GetObjectGuid());
                    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 (!bApply || pAura->GetTarget()->GetTypeId() != TYPEID_UNIT)
                return false;

            Creature* pTarget = (Creature*)pAura->GetTarget();

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

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

            return false;
        }
        case SPELL_SHROUD_OF_DEATH:
        case SPELL_SPIRIT_PARTICLES:
        {
            Creature* pCreature = (Creature*)pAura->GetTarget();

            if (!pCreature || (pCreature->GetEntry() != NPC_FRANCLORN_FORGEWRIGHT && pCreature->GetEntry() != NPC_GAERIYAN && pCreature->GetEntry() != NPC_GANJO))
                return false;

            if (bApply)
                pCreature->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE;
            else
                pCreature->m_AuraFlags &= ~UNIT_AURAFLAG_ALIVE_INVISIBLE;

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

            Unit* pTarget = pAura->GetTarget();
            if (bApply && pTarget->GetTypeId() == TYPEID_UNIT)
                ((Creature*)pTarget)->UpdateEntry(NPC_ENCASED_ELECTROMENTAL);
            return true;
        }
    }

    return false;
}
Example #21
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (step)
        {
            if (timer < uiDiff)
            {
                Creature* curr = NULL;
                switch (step)
                {
                    case 1:
                        float fX, fY, fZ;
                        if (GameObject* pKeg = me->FindNearestGameObject(GO_TAINTED_KEG, 10.000000))
                        {
                            std::list<Creature*> lCrea;
                            me->GetCreatureListWithEntryInGrid(lCrea, NPC_CAPTURED_FARMER, 30.0f);
                            for (std::list<Creature*>::iterator it = lCrea.begin(); it != lCrea.end(); ++it)
                            {
                                if ((*it)->isAlive())
                                {
                                    Farmers.push_back((*it)->GetGUID());
                                    pKeg->GetContactPoint((*it), fX, fY, fZ, CONTACT_DISTANCE);
                                    (*it)->GetMotionMaster()->MovePoint(1, fX, fY, fZ, MOVE_PATHFINDING);
                                }
                            }
                        }
                        timer = 4500;
                        step++;
                        break;
                    case 2:
                        if (curr = me->GetMap()->GetCreature(Farmers.front()))
                            curr->SetStandState(UNIT_STAND_STATE_KNEEL);
                        timer = 2000;
                        step++;
                        break;
                    case 3:
                        if (GameObject* pBaril = me->FindNearestGameObject(GO_TAINTED_KEG, 10.000000))
                        {
                            float fX, fY, fZ;
                            pBaril->GetPosition(fX, fY, fZ);
                            me->SummonGameObject(GO_TAINTED_KEG_SMOKE, fX, fY, fZ + 1, 0, 0, 0, 0, 0, 120);
                        }
                        if (curr = me->GetMap()->GetCreature(Farmers.front()))
                            curr->SetStandState(UNIT_STAND_STATE_STAND);
                        curr = NULL;
                        while (!Farmers.empty())
                        {
                            if (curr = me->GetMap()->GetCreature(Farmers.front()))
                                curr->DealDamage(curr, curr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                            Farmers.pop_front();
                            curr = NULL;
                        }

                        timer = 20000;
                        step++;
                        break;
                    case 4:
                        timer = 0;
                        step = 0;
                        break;
                }
            }
            else
                timer -= uiDiff;
        }
    }
Example #22
0
bool EffectAuraDummy_spell_aura_dummy_npc(const Aura* pAura, bool bApply)
{
    switch(pAura->GetId())
    {
        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 (!bApply || pAura->GetTarget()->GetTypeId() != TYPEID_UNIT)
                return false;

            Creature* pTarget = (Creature*)pAura->GetTarget();

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

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

            return false;
        }
    }

    return false;
}
Example #23
0
 void WaypointReached(uint32 i)
 {
     switch (Part)
     {
         case 1:
             switch (i)
             {
                 case 0:
                     if (GameObject* door = FindGameObject(GO_PRISON_DOOR, INTERACTION_DISTANCE, me))
                         door->UseDoorOrButton(6);
                     break;
                 case 7:
                     if (Creature* Armorer = me->SummonCreature(NPC_ARMORER, 2180.95f, 119.19f, 89.456f, 5.692f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 35000))
                         DoScriptText(SAY_ARMORER_CALL_GUARDS, Armorer);
                     break;
                 case 8:
                     SetRun(false);
                     break;
                 case 9:
                     DoScriptText(SAY_TH_KILL_ARMORER, me);
                     DoCast(me, SPELL_KNOCKOUT_ARMORER);
                     if (Creature* Armorer = me->GetMap()->GetCreature(ArmorerGUID))
                         Armorer->setDeathState(JUST_DIED);
                     break;
                 case 10:
                     DoScriptText(SAY_TH_ARMORY, me);
                     me->SetStandState(UNIT_STAND_STATE_KNEEL);
                     break;
                 case 11:
                     me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, THRALL_WEAPON_MODEL);
                     me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, THRALL_WEAPON_INFO);
                     me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 781);
                     me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, THRALL_SHIELD_MODEL);
                     me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, THRALL_SHIELD_INFO);
                     me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 1038);
                     me->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_EQUIPPED);
                     me->SetStandState(UNIT_STAND_STATE_STAND);
                     SetRun();
                     break;
                 case 12:
                     if (Player* player = GetPlayerForEscort())
                         me->SetFacingToObject(player);
                     DoScriptText(SAY_TH_ARMORY_2, me);
                     break;
                 case 17:
                     me->SummonCreature(NPC_MAGE, 2186.909f, 139.8108f, 88.21628f, 5.75f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_WARDEN, 2187.943f, 141.6124f, 88.21628f, 5.73f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_VETERAN, 2190.508f, 140.4597f, 88.21628f, 6.04f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_VETERAN, 2189.543f, 139.0996f, 88.23965f, 0.21f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     break;
                 case 20:
                     me->SummonCreature(NPC_MAGE, 2149.463f, 104.9756f, 73.63239f, 1.71f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_SENTRY, 2147.642f, 105.0251f, 73.99422f, 1.52f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_VETERAN, 2149.212f, 107.2005f, 74.15676f, 1.71f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_WARDEN, 2147.328f, 106.7235f, 74.34447f, 1.69f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     break;
                 case 23:
                     me->SummonCreature(NPC_MAGE, 2142.363f, 172.4260f, 66.30494f, 2.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_SENTRY, 2138.177f, 168.6046f, 66.30494f, 2.47f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_SENTRY, 2142.372f, 174.2907f, 66.30494f, 2.56f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_VETERAN, 2140.146f, 169.2364f, 66.30494f, 2.49f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     break;
                 case 25:
                     me->SummonCreature(NPC_MAGE, 2107.938f, 192.0753f, 66.30494f, 2.54f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_MAGE, 2109.852f, 195.1403f, 66.30493f, 2.42f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_VETERAN, 2108.486f, 189.9346f, 66.30494f, 2.68f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_VETERAN, 2112.387f, 195.4947f, 66.30494f, 2.39f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     break;
                 case 31:
                     me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_POINT);
                     EmoteTimer = 2000;
                     me->SetFacingTo(2.18f);
                     me->SummonCreature(NPC_SKARLOC, 2000.201f, 277.9190f, 66.4911f, 6.11f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                     DoScriptText(SAY_TH_SKARLOC_MEET, me);
                     break;
                 case 33:
                     me->SetFacingTo(2.18f);
                     DoScriptText(SAY_THRALL_END_P1, me);
                     me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                     break;
             }
             break;
         case 2:
             switch (i)
             {
                 case 1:
                     DoScriptText(SAY_TH_MOUNTS_UP, me);
                     DoMount();
                     if (Creature* mount = me->GetCreature(me->GetMap()->GetCreatureGUID(NPC_SKARLOC_MOUNT)))
                         mount->ForcedDespawn();
                     SetRun();
                     break;
                 case 29:
                     me->SummonCreature(NPC_SKARLOC_MOUNT, 2488.64f, 625.77f, 58.26, 4.71f,TEMPSUMMON_TIMED_DESPAWN,10000);
                     DoUnmount();
                     HadMount = false;
                     SetRun(false);
                     break;
                 case 30:
                     if (Creature* mount = me->GetMap()->GetCreature(MountGUID))
                         me->SetFacingToObject(mount);
                     DoScriptText(EMOTE_TH_STARTLE_HORSE, me);
                     me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_EXCLAMATION);
                     EmoteTimer = 2000;
                     break;
                 case 31:
                     if (Creature* mount = me->GetMap()->GetCreature(MountGUID))
                     {
                         mount->SetWalk(false);
                         mount->GetMotionMaster()->MovePoint(0, 2517.504f, 506.253f, 42.329f);
                     }
                     me->SetFacingTo(4.66f);
                     me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                     pInstance->SetData(TYPE_THRALL_PART2, DONE);
                     break;
             }
             break;
         case 3:
             switch (i)
             {
                 case 3:
                     SetRun(false);
                     break;
                 case 6:
                     DoScriptText(EMOTE_TH_CALM_HORSE, me);
                     break;
                 case 9:
                     me->SummonCreature(NPC_TARREN_MILL_PROTECTOR, 2510.16f, 693.98f, 55.50f, 2.84f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                     me->SummonCreature(NPC_TARREN_MILL_LOOKOUT, 2510.02f, 697.72f, 55.51f, 3.38f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                     me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2507.83f, 693.76f, 55.50f, 3.14f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                     me->SummonCreature(NPC_TARREN_MILL_GUARDSMAN, 2508.22f, 698.00f, 55.50f, 3.14f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000);
                     break;
                 case 13:
                     DoScriptText(SAY_TH_HEAD_TOWN, me);
                     SetRun();
                     break;
                 case 24:
                     if (Player* player = GetPlayerForEscort())
                         me->SetFacingToObject(player);
                     DoScriptText(SAY_TH_CHURCH_ENTER, me);
                     break;
                 case 25:
                     me->SummonCreature(NPC_CHURCH_PROTECTOR, 2627.88f, 657.63f, 55.98f, 4.28f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_CHURCH_LOOKOUT, 2627.27f, 655.17f, 56.03f, 4.50f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_CHURCH_LOOKOUT, 2629.21f, 654.81f, 56.04f, 4.38f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_CHURCH_GUARDSMAN, 2629.98f, 656.96f, 55.96f, 4.34f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     break;
                 case 27:
                     DoScriptText(SAY_TH_CHURCH_END, me);
                     break;
                 case 35:
                     me->SummonCreature(NPC_INN_PROTECTOR, 2652.71f, 660.31f, 61.93f, 1.67f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_INN_LOOKOUT, 2648.96f, 662.59f, 61.93f, 0.79f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_INN_LOOKOUT, 2657.36f, 662.34f, 61.93f, 2.68f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     me->SummonCreature(NPC_INN_GUARDSMAN, 2656.39f, 659.77f, 61.93f, 2.61f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                     break;
                 case 36:
                     SetRun(false);
                     break;
                 case 37:
                     if (Creature* Taretha = me->GetMap()->GetCreature(TarethaGUID))
                         DoScriptText(SAY_TA_ESCAPED, Taretha, me);
                     break;
                 case 38:
                     pInstance->SetData(TYPE_THRALL_PART3,DONE);
                     DoScriptText(SAY_TH_MEET_TARETHA, me);
                     me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                     break;
             }
             break;
         case 4:
             switch (i)
             {
                 case 0:
                    if (Creature* Epoch = me->SummonCreature(NPC_EPOCH,2639.13,698.55,65.43,4.59,TEMPSUMMON_DEAD_DESPAWN,120000))
                        DoScriptText(SAY_EPOCH_ENTER1, Epoch);
                     me->SetFacingTo(2.63f);
                     DoScriptText(SAY_TH_EPOCH_WONDER, me);
                     break;
                 case 1:
                     me->SetFacingTo(5.79f);
                     DoScriptText(SAY_TH_EPOCH_KILL_TARETHA, me);
                     if (Creature* Epoch = me->GetMap()->GetCreature(EpochGUID))
                         DoScriptText(SAY_EPOCH_ENTER2, Epoch);
                     if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA))
                     {
                         Creature* Taretha = (Unit::GetCreature(*me, TarethaGUID));
                         Taretha->CastSpell(Taretha, SPELL_SHADOW_SPIKE, true);
                         Taretha->SetStandState(UNIT_STAND_STATE_DEAD);
                     }
                     break;
                 case 9:
                     if (Creature* Epoch = me->GetMap()->GetCreature(EpochGUID))
                     {
                         DoScriptText(SAY_EPOCH_ENTER3, Epoch);
                         me->SetFacingToObject(Epoch);
                     }
                     SetEscortPaused(true);
                     break;
                 case 11:
                     if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA))
                     {
                         Creature* Taretha = (Unit::GetCreature(*me, TarethaGUID));
                         if (Player* pPlayer = GetPlayerForEscort())
                             CAST_AI(npc_escortAI, (Taretha->AI()))->Start(false, true, pPlayer->GetGUID());
                     }
                     Event = true;
                     me->SetFacingTo(5.79f);
                     SetEscortPaused(true);
                     break;
                 case 13:
                     Event = false;
                     pInstance->SetData(TYPE_THRALL_EVENT, DONE);
                     break;
             }
             break;
     }
 }
Example #24
0
void GameEventMgr::ScriptedBackToOrig(uint32 event_id)
{
	GameEventScriptMap::iterator event_backup = m_GameEventScriptBackup.find(event_id);
	if( event_backup == m_GameEventScriptBackup.end() )
		return;

	set<EventScript*>::iterator itr = event_backup->second.begin();
	for( itr; itr != event_backup->second.end(); itr++ )
	{
		uint32 mapid = (*itr)->mapid;
		uint32 sql_id = (*itr)->sql_id;
		uint8 type = (*itr)->type;
		uint32 data1 = (*itr)->data_1;
		uint32 data2 = (*itr)->data_2;
		uint32 data3 = (*itr)->data_3;

		MapMgr * mapmgr = sInstanceMgr.GetMapMgr( mapid );
		if( mapmgr == NULL )
			return;

		Creature *c;
		GameObject *go;
		if(type < GAMEOBJECT_CHANGE_STATE)
		{
			c = mapmgr->GetSqlIdCreature( sql_id );
			if( c == NULL ) return;
		}
		else
		{
			go = mapmgr->GetSqlIdGameObject( sql_id );
			if( go == NULL ) return;
		}

		switch( type )
		{
			case CREATURE_CHANGE_SCRIPTED_CHANGE:
			{
				CALL_SCRIPT_EVENT(c, GameEventFinish)(event_id);
			} break;
			case CREATURE_CHANGE_EMOTE:
			{
				c->Emote(EmoteType(data1));
				c->SetEmoteState(data2);
				c->SetStandState(static_cast<uint8>(data3));
			} break;

			case CREATURE_CHANGE_DISPLAYID:
			{
				c->SetDisplayId(data1);
				c->SetNativeDisplayId(data2);
				c->SetMount(data3);

				c->EventModelChange();
			} break;

			case CREATURE_CHANGE_WEAPON:
			{
				c->SetEquippedItem(MELEE, data1);
				c->SetEquippedItem(OFFHAND, data2);
				c->SetEquippedItem(RANGED, data3);
			} break;

			case CREATURE_CHANGE_REACT:
			{
				c->SetFaction(data1);
				c->SetUInt32Value(UNIT_NPC_FLAGS, data2);
				c->SetUInt32Value(UNIT_FIELD_FLAGS, data3);
			} break;

			case CREATURE_CAST_SPELL_ON_EVENT_STOP:
			{
				SpellEntry * sp = dbcSpell.LookupEntryForced( data1 );
				if( sp == NULL )
					return;

				SpellCastTime * casttime = dbcSpellCastTime.LookupEntry(sp->CastingTimeIndex);
				Spell * spell = sSpellFactoryMgr.NewSpell(c, sp, false, NULL);

				SpellCastTargets t(0);

				// force self casting
				if( data2 )
				{
					t.m_unitTarget = c->GetGUID();
				}
				else
				{
					spell->GenerateTargets(&t);
					spell->m_targets = t;
				}

				if (objmgr.IsSpellDisabled(spell->GetProto()->Id) || spell->CanCast(false) != SPELL_CANCAST_OK || !spell->HasPower() || c->m_silenced || c->IsStunned() || c->IsFeared() )
				{
					delete spell;
					return;
				}

				if( casttime->CastTime > 0 )
					c->GetAIInterface()->StopMovement(casttime->CastTime);

				spell->prepare(&t);

			} break;

			case CREATURE_CHANGE_UPDATE_FIELD:
			{
				c->SetUInt32Value(data1, data2);
			} break;

			case GAMEOBJECT_CHANGE_STATE:
			{
				go->SetState((uint8)data1);
			} break;
		}
	}

	m_GameEventScriptBackup.erase(event_id);
}
Example #25
0
bool AI_Movement::showWayPoints(Player* pPlayer, bool Backwards)
{
	ASSERT(m_Unit != NULL);

	if(!m_waypoints)
		return false;

	//wpid of 0 == all
	WayPointMap::const_iterator itr;
	if(m_WayPointsShowing == true)
		return false;

	m_WayPointsShowing = true;

	WayPoint* wp = NULL;
	for (itr = m_waypoints->begin(); itr != m_waypoints->end(); itr++)
	{
		if( (*itr) != NULL )
		{
			wp = *itr;

			//Create
			Creature* pWayPoint = NULLCREATURE;
			pWayPoint = new Creature((uint64)HIGHGUID_TYPE_WAYPOINT << 32 | wp->id);
			pWayPoint->Init();
			pWayPoint->CreateWayPoint(wp->id, pPlayer->GetMapId(), wp->x, wp->y, wp->z, wp->orientation);
			pWayPoint->SetUInt32Value(OBJECT_FIELD_ENTRY, 300000);
			pWayPoint->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);

			bool ModelChange = false;
			if(!Backwards)
			{
				if(wp->forwardInfo)
				{
					uint32 DisplayID = (wp->forwardInfo->SkinID == 0) ? m_Unit->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID) : wp->forwardInfo->SkinID;
					if(DisplayID != m_Unit->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID))
						ModelChange = true;

					pWayPoint->SetUInt32Value(UNIT_FIELD_DISPLAYID, DisplayID);
					pWayPoint->SetUInt32Value(UNIT_NPC_EMOTESTATE, wp->forwardInfo->EmoteID);
					pWayPoint->SetStandState(wp->forwardInfo->StandState);
				}
			}
			else
			{
				if(wp->backwardInfo)
				{
					uint32 DisplayID = (wp->backwardInfo->SkinID == 0) ? m_Unit->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID) : wp->backwardInfo->SkinID;
					if(DisplayID != m_Unit->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID))
						ModelChange = true;

					pWayPoint->SetUInt32Value(UNIT_FIELD_DISPLAYID, DisplayID);
					pWayPoint->SetUInt32Value(UNIT_NPC_EMOTESTATE, wp->backwardInfo->EmoteID);
					pWayPoint->SetStandState(wp->backwardInfo->StandState);
				}
			}
			if(ModelChange)
				pWayPoint->EventModelChange();

			pWayPoint->SetUInt32Value(UNIT_FIELD_LEVEL, wp->id);
			pWayPoint->SetUInt32Value(UNIT_NPC_FLAGS, 0);
//			pWayPoint->SetUInt32Value(UNIT_FIELD_AURA+32, 8326); //invisable & deathworld look
			pWayPoint->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE , pPlayer->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE));
			pWayPoint->SetUInt32Value(UNIT_FIELD_HEALTH, 1);
			pWayPoint->SetUInt32Value(UNIT_FIELD_MAXHEALTH, 1);
			pWayPoint->SetUInt32Value(UNIT_FIELD_STAT0, wp->flags);

			//Create on client
			ByteBuffer buf(2500);
			uint32 count = pWayPoint->BuildCreateUpdateBlockForPlayer(&buf, pPlayer);
			pPlayer->PushCreationData(&buf, count);

			//root the object
			WorldPacket data1;
			data1.Initialize(SMSG_FORCE_MOVE_ROOT);
			data1 << pWayPoint->GetNewGUID();
			pPlayer->GetSession()->SendPacket( &data1 );

			//Cleanup
			delete pWayPoint;
			pWayPoint = NULL;
		}
	}
	return true;
}