示例#1
0
// this method is used to check which event to activate etc.
void GameEventMgr::CheckForEvents()
{
	GameEventMap::iterator itr = m_GameEventMap.begin();
	uint32 current_time = mktime(&g_localTime);

	for( itr; itr != m_GameEventMap.end(); itr++ )
	{
		EventInfo * ev = itr->second;

		//   current time > start time        current time < end time            not active yet
		if( (ev->start_time < current_time) && (ev->end_time > current_time) && (ev->active == false) )
		{
			StartEvent(itr->first);
		}
		//            is active            end time < current time
		else if( (ev->active == true) && (ev->end_time < current_time) )
		{
			FinishEvent(itr->first);
		}
		// let's call this dirty bug fix, in very small percent of all performed actions it may happen
		else if( (ev->active == false) && ev->end_time < current_time )
		{
			// re-calculate start time :<
			// REMEMBER that in this case we must use UNIXTIME, because we use UNIXTIME relative to your time zone only for checks
			uint32 tdiff = (current_time - ev->end_time) / ev->occurence;
			ev->start_time += (tdiff + 1) * ev->occurence;

			// set the end_time again
			ev->end_time = ev->start_time + ev->length;
			sGameEventMgr.SaveEvent( itr->first );
		}

		// otherwise do nothing
	}
}
        void MoveInLineOfSight(Unit *who)
        {
            if (!Intro)
            {
                Intro = true;
                DoScriptText(SAY_INTRO, me);
            }
            if (!CanAttack)
                return;
            if (!who || me->getVictim())
                return;

            if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me) && me->IsHostileTo(who))
            {
                float attackRadius = me->GetAttackDistance(who);
                if (me->IsWithinDistInMap(who, attackRadius) && me->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && me->IsWithinLOSInMap(who))
                {
                    //if (who->HasStealthAura())
                    //    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);

                    if (!me->isInCombat())//AttackStart() sets UNIT_FLAG_IN_COMBAT, so this msut be before attacking
                        StartEvent();

                    if (Phase != 2)
                        AttackStart(who);
                }
            }
        }
示例#3
0
    void Aggro(Unit* who)
    {
        StartEvent();

        DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL);
        DoPlaySoundToSet(m_creature, SOUND_AGGRO);
        AddsAttack();
    }
 void Aggro(Unit *who)
 {
     if(!InCombat)
     {   
         InCombat = true;
         StartEvent();
     }
 }
示例#5
0
        void EnterCombat(Unit* /*who*/)
        {
            StartEvent();

            DoScriptText(SAY_AGGRO, me);
            AddsAttack();
            DoZoneInCombat();
        }
示例#6
0
    void EnterCombat(Unit* who)
    {
        StartEvent();

        DoScriptText(SAY_AGGRO, m_creature);
        AddsAttack();
        DoZoneInCombat();
    }
示例#7
0
        void EnterCombat(Unit* /*who*/)
        {
            StartEvent();

            Talk(SAY_AGGRO);
            AddsAttack();
            DoZoneInCombat();
        }
示例#8
0
 void SpellHit(Unit * caster, const SpellInfo * spell)
 {
     if(spell->Id == SPELL_FIREWORKS)
     {
         DoCast(me, SPELL_FIREWORKS_VISUAL, true);
         StartEvent(caster->ToPlayer());
     }
 }
示例#9
0
    void Aggro(Unit *who)
    {
        //Begin melee attack if we are within range
        if(Phase != 2)
            DoStartAttackAndMovement(who);

        StartEvent();
    }
示例#10
0
 void DoAction(const int32 actionId)
 {
     switch(actionId)
     {
         case ACTION_START_INTRO:
             StartEvent();
             break;
     }
 }
示例#11
0
    void EnterCombat(Unit *who)
    {
        RemoveTaintedCore();

        if(Phase != 2)
            AttackStart(who);

        if(!InCombat)
            StartEvent();
    }
示例#12
0
 void MovementInform(uint32 type, uint32 id)
 {
     if (type != POINT_MOTION_TYPE)
         return;
     if (id == 1)
     {
         StartEvent();
         me->SetOrientation(MedivPos[3]);
         me->SetOrientation(MedivPos[3]);
     }
 }
void ControllerAI::DoAction(const int32 action)
{
    switch (action)
    {
        case ACTION_START_EVENT:     { StartEvent(); }break;
        case ACTION_RESET_EVENT:     { ResetEvent(); }break;
        case ACTION_ENABLE_KADDRAK:  { ActivateBoss(EVENT_KADDRAK_CAST_SPELL);  }break;
        case ACTION_ENABLE_MARNAK:   { ActivateBoss(EVENT_MARNAK_CAST_SPELL);   }break;
        case ACTION_ENABLE_ABEDNEUM: { ActivateBoss(EVENT_ABEDNEUM_CAST_SPELL); }break;
        case ACTION_SET_ALL_GO_WHITE:{ ActivateOrSwitchBossGO(BOSS_ALL, BOSS_GO_STATE_ACTIVE_WHITE); }break;
    }
}
        void JustEngagedWith(Unit* who) override
        {
            // remove old tainted cores to prevent cheating in phase 2
            Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
                if (Player* player = itr->GetSource())
                    player->DestroyItemCount(31088, 1, true);
            StartEvent(); // this is JustEngagedWith(), so were are 100% in combat, start the event

            if (Phase != 2)
                AttackStart(who);
        }
    void UpdateAI(const uint32 diff)
    {
         if(!m_pInstance)
             return;

        if(m_pInstance->GetData(TYPE_EVENT) == 1
           &&  m_pInstance->GetData64(DATA_ESCAPE_LIDER) == m_creature->GetGUID())
           StartEvent();

        if(m_pInstance->GetData(TYPE_EVENT) == 2
           &&  m_pInstance->GetData64(DATA_ESCAPE_LIDER) == m_creature->GetGUID())
        {
            Small = true;
            StartEvent();
        }

         if(StepTimer < diff && m_pInstance->GetData(TYPE_PHASE) == 1)
            Event();
         else StepTimer -= diff;

         return;
     }
示例#16
0
// return the next event delay in ms
uint32 GameEventMgr::Update(ActiveEvents const* activeAtShutdown /*= nullptr*/)
{
    time_t currenttime = time(nullptr);

    uint32 nextEventDelay = max_ge_check_delay;             // 1 day
    uint32 calcDelay;
    for (uint16 itr = 1; itr < mGameEvent.size(); ++itr)
    {
        if (mGameEvent[itr].occurence == 0)
            continue;
        // sLog.outErrorDb("Checking event %u",itr);
        if (CheckOneGameEvent(itr, currenttime))
        {
            // DEBUG_LOG("GameEvent %u is active",itr->first);
            if (!IsActiveEvent(itr))
            {
                if (mGameEvent[itr].linkedTo == 0 || IsActiveEvent(mGameEvent[itr].linkedTo))
                {
                    bool resume = activeAtShutdown && (activeAtShutdown->find(itr) != activeAtShutdown->end());
                    StartEvent(itr, false, resume);
                }
            }
        }
        else
        {
            // DEBUG_LOG("GameEvent %u is not active",itr->first);
            if (IsActiveEvent(itr))
            {
                StopEvent(itr);
                if (mGameEvent[itr].linkedTo != 0)
                    StopEvent(mGameEvent[itr].linkedTo);
            }
            else
            {
                if (!m_IsGameEventsInit)
                {
                    int16 event_nid = (-1) * (itr);
                    // spawn all negative ones for this event
                    GameEventSpawn(event_nid);
                    UpdateWorldStates(itr, false);
                }
            }
        }
        calcDelay = NextCheck(itr);
        if (calcDelay < nextEventDelay)
            nextEventDelay = calcDelay;
    }
    BASIC_LOG("Next game event check in %u seconds.", nextEventDelay + 1);
    return (nextEventDelay + 1) * IN_MILLISECONDS;          // Add 1 second to be sure event has started/stopped at next call
}
示例#17
0
        void CheckBanish()
        {
            uint8 AliveChannelers = 0;
            for (uint8 i = 0; i < 3; ++i)
            {
                Unit *add = Unit::GetUnit(*me, SpellBinderGUID[i]);
                if (add && add->isAlive())
                    ++AliveChannelers;
            }

            // channelers == 0 remove banish aura
            if (AliveChannelers == 0 && me->HasAura(AURA_BANISH))
            {
                // removing banish aura
                me->RemoveAurasDueToSpell(AURA_BANISH);

                // Leotheras is getting immune again
                me->ApplySpellImmune(AURA_BANISH, IMMUNITY_MECHANIC, MECHANIC_BANISH, true);

                // changing model to bloodelf
                me->SetDisplayId(MODEL_NIGHTELF);

                // and reseting equipment
                me->LoadEquipment(me->GetEquipmentId());

                if (pInstance && pInstance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
                {
                    Unit* victim = NULL;
                    victim = Unit::GetUnit(*me, pInstance->GetData64(DATA_LEOTHERAS_EVENT_STARTER));
                    if (victim)
                        me->getThreatManager().addThreat(victim, 1);
                    StartEvent();
                }
            }
            else if (AliveChannelers != 0 && !me->HasAura(AURA_BANISH))
            {
                // channelers != 0 apply banish aura
                // removing Leotheras banish immune to apply AURA_BANISH
                me->ApplySpellImmune(AURA_BANISH, IMMUNITY_MECHANIC, MECHANIC_BANISH, false);
                DoCast(me, AURA_BANISH);

                // changing model
                me->SetDisplayId(MODEL_DEMON);

                // and removing weapons
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID  , 0);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
            }
        }
示例#18
0
    void UpdateAI(const uint32 diff)
    {
        // Event started by entering combat with gauntlet mob
        if(!EventStarted && pInstance && pInstance->GetData(DATA_AKILZONGAUNTLET) != AKILZON_GAUNTLET_NOT_STARTED)
        {
            StartEvent();
        }

        if(Move)
        {
            me->GetMotionMaster()->MovePoint(MovePoint, GauntletWP[MovePoint][0], GauntletWP[MovePoint][1], GauntletWP[MovePoint][2]);
            Move = false;
        }

        else if (pInstance && pInstance->GetData(DATA_AKILZONGAUNTLET) == AKILZON_GAUNTLET_IN_PROGRESS)
        {
            if(warriorsTimer < diff)
            {
                for(uint8 i = 0; i < 2; i++)
                    me->SummonCreature(NPC_AMANISHI_WARRIOR, GauntletWP[0][0] + 2*i, GauntletWP[0][1] + 2*i, GauntletWP[0][2], 3.1415f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
                warriorsTimer = 40000;
            }
            else
                warriorsTimer -= diff;

            if(eaglesTimer < diff)
            {
                uint8 maxEagles = RAND(5, 6);
                for(uint8 i = 0; i < maxEagles; i++)
                    me->SummonCreature(NPC_AMANISHI_EAGLE, GauntletWP[4][0] + 2*(i%2)-4, GauntletWP[4][1] + 2*(i/2) - 4, GauntletWP[4][2], 3.1415f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
                eaglesTimer = 25000;
            }
            else
                eaglesTimer -= diff;
        }

        else if(pInstance && pInstance->GetData(DATA_AKILZONGAUNTLET) == AKILZON_GAUNTLET_TEMPEST_DEAD)
        {
            Reset();
            me->Kill(me, false);
        }

        if(EventStarted && !UpdateVictim())
        {
            EnterEvadeMode();
            EventStarted = false;
            Summons.DespawnAll();
        }
    }
示例#19
0
 bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
 {
     uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
     ClearGossipMenuFor(player);
     switch (action)
     {
         case GOSSIP_ACTION_INFO_DEF + 1:
             StartEvent(player);
             break;
         case GOSSIP_ACTION_INFO_DEF + 2:
             FirstBossDead = true;
             WaveCount = 9;
             StartEvent(player);
             break;
         case GOSSIP_ACTION_INFO_DEF + 3:
             Retreat();
             break;
         case GOSSIP_ACTION_INFO_DEF:
             Debug = !Debug;
             TC_LOG_DEBUG("scripts", "HyjalAI - Debug mode has been toggled");
             break;
     }
     return true;
 }
示例#20
0
void C_SceneEntity::CheckQueuedEvents()
{
// Check for duplicates
	CUtlVector< QueuedEvents_t > events;
	events = m_QueuedEvents;
	m_QueuedEvents.RemoveAll();

	int c = events.Count();
	for ( int i = 0; i < c; ++i )
	{
		const QueuedEvents_t& check = events[ i ];
		
		// Retry starting this event
		StartEvent( check.starttime, check.scene, check.event );
	}
}
示例#21
0
        void EnterCombat(Unit* who)
        {
            if (instance)
            {
                // remove old tainted cores to prevent cheating in phase 2
                Map* map = me->GetMap();
                Map::PlayerList const &PlayerList = map->GetPlayers();
                for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
                    if (Player* player = itr->getSource())
                        player->DestroyItemCount(31088, 1, true);
            }
            StartEvent(); // this is EnterCombat(), so were are 100% in combat, start the event

            if (Phase != 2)
                AttackStart(who);
        }
示例#22
0
    void MoveInLineOfSight(Unit *who)
    {
        if(me->getVictim())
            return;
       // if(EventStarted)
       //     return;

        if (me->canStartAttack(who))
        {
            AttackStart(who);
            who->CombatStart(me);
            StartEvent();
            if(pInstance)
                pInstance->SetData(DATA_AKILZONGAUNTLET, AKILZON_GAUNTLET_IN_PROGRESS);
        }
    }
示例#23
0
    void EnterCombat(Unit *who)
    {
        if (pInstance)
        {
            //remove old tainted cores to prevent cheating in phase 2
            Map* pMap = m_creature->GetMap();
            Map::PlayerList const &PlayerList = pMap->GetPlayers();
            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
            {
                if (Player* i_pl = i->getSource())
                {
                    i_pl->DestroyItemCount(31088, 1, true);
                }
            }
        }
        StartEvent();//this is EnterCombat(), so were are 100% in combat, start the event

        if (Phase != 2)
            AttackStart(who);
    }
示例#24
0
 void IsSummonedBy(Unit* /*summoner*/) override
 {
     std::list<Player*> playerOnQuestList;
     Trinity::AnyPlayerInObjectRangeCheck checker(me, 5.0f);
     Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, playerOnQuestList, checker);
     me->VisitNearbyWorldObject(5.0f, searcher);
     for (std::list<Player*>::const_iterator itr = playerOnQuestList.begin(); itr != playerOnQuestList.end(); ++itr)
     {
         // Check if found player target has active quest
         if (Player* player = (*itr))
         {
             if (player->GetQuestStatus(10965) == QUEST_STATUS_INCOMPLETE)
             {
                 StartEvent(player);
                 break;
             }
         }
         else
             break;
     }
 }
示例#25
0
uint32 GameEventMgr::Update()                               // return the next event delay in ms
{
    uint32 nextEventDelay = max_ge_check_delay;             // 1 day
    uint32 calcDelay;
    for (uint16 itr = 1; itr < mGameEvent.size(); ++itr)
    {
        //sLog.outErrorDb("Checking event %u",itr);
        if (CheckOneGameEvent(itr))
        {
            //DEBUG_LOG("GameEvent %u is active",itr->first);
            if (!IsActiveEvent(itr))
                StartEvent(itr);
        }
        else
        {
            //DEBUG_LOG("GameEvent %u is not active",itr->first);
            if (IsActiveEvent(itr))
                StopEvent(itr);
            else
            {
                if (!m_IsGameEventsInit)
                {
                    int16 event_nid = (-1) * (itr);
                    // spawn all negative ones for this event
                    GameEventSpawn(event_nid);

                    // disable any event specific quest (for cases where creature is spawned, but event not active).
                    UpdateEventQuests(itr, false);
                    UpdateWorldStates(itr, false);
                }
            }
        }
        calcDelay = NextCheck(itr);
        if (calcDelay < nextEventDelay)
            nextEventDelay = calcDelay;
    }
    BASIC_LOG("Next game event check in %u seconds.", nextEventDelay + 1);
    return (nextEventDelay + 1) * IN_MILLISECONDS;           // Add 1 second to be sure event has started/stopped at next call
}
示例#26
0
//内核初始化函数
bool CBaseMainManageForZ::AFCKernelStart()
{
	if ((m_hWindow!=NULL)&&(::IsWindow(m_hWindow)==TRUE)) return false;

	//建立事件
	CEvent StartEvent(FALSE,TRUE,NULL,NULL);
	if (StartEvent==NULL) throw new CAFCException(TEXT("CBaseMainManageForZ::AFCKernelStart 事件建立失败"),0x420);

	//建立线程
	WindowThreadStartStruct ThreadData;
	ThreadData.bSuccess=FALSE;
	ThreadData.pMainManage=this;
	ThreadData.hEvent=StartEvent;

	UINT uThreadID=0;
	m_hWindowThread=(HANDLE)::_beginthreadex(NULL,0,WindowMsgThread,&ThreadData,0,&uThreadID);
	if (m_hWindowThread==NULL) throw new CAFCException(TEXT("CBaseMainManageForZ::AFCKernelStart WindowMsgThread 线程建立失败"),0x421);
	::WaitForSingleObject(ThreadData.hEvent,INFINITE);
	if (ThreadData.bSuccess==FALSE) throw new CAFCException(TEXT("CBaseMainManageForZ::AFCKernelStart WindowMsgThread 线程建立失败"),0x422);

	return true;
}
示例#27
0
//.event start
bool ChatHandler::HandleEventStartEvent(const char* args, WorldSession* m_session)
{
    uint32 eventid = atoi(args);
    if (eventid == 0)
    {
        SystemMessage(m_session, "Invalid argument: %s", args);
        return false;
    }

    for (auto eventPair : sGameEventMgr.mGameEvents)
    {
        auto gameEvent = eventPair.second;
        if (gameEvent->event_id == eventid)
        {
            SystemMessage(m_session, "Force starting event %u (%s)", gameEvent->event_id, gameEvent->description.c_str());
            gameEvent->StartEvent(true);
            return true;
        }
    }

    SystemMessage(m_session, "Game event with ID %u not found", eventid);
    return false;
}
示例#28
0
 void EnterCombat(Unit* who)
 {
     StartEvent(who);
 }
示例#29
0
 void Reset()
 {
     SparkGUID = 0;
     Step = 0;
     StartEvent();
 }
 void EnterCombat(Unit* /*who*/)
 {
     PlayerList = &me->GetMap()->GetPlayers();
     Playercount = PlayerList->getSize();
     StartEvent();
 }