Beispiel #1
0
void BattlegroundRL::Update (uint32 diff)
{
    Battleground::Update(diff);

    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 47 * MINUTE * IN_MILLISECONDS)          // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }
    }
}
Beispiel #2
0
void BattlegroundDS::Update(uint32 diff)
{
    Battleground::Update(diff);

    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS)    // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }
    }

    if (getWaterFallTimer() < diff)
    {
        if (GetBgMap(false))
            if (isWaterFallActive())
            {
                setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, getWaterFallTimer());
                setWaterFallActive(false);
            }
            else
            {
                setWaterFallTimer(BG_DS_WATERFALL_DURATION);
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, RESPAWN_IMMEDIATELY);
                setWaterFallActive(true);
            }
    }
    else
        setWaterFallTimer(getWaterFallTimer() - diff);

    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if(m_knockback < diff && m_knockbackCheck)
        {
            for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); itr++)
            {
                Player * plr = sObjectMgr->GetPlayer(itr->first);
                if (plr->GetTeam() == ALLIANCE && plr->GetDistance2d(1214, 765) <= 50 && plr->GetPositionZ() > 10)
                    KnockBackPlayer(plr, 6.15f, 50.00f, 7.00f);
                if (plr->GetTeam() == HORDE && plr->GetDistance2d(1369, 817) <= 50 && plr->GetPositionZ() > 10)
                    KnockBackPlayer(plr, 3.10f, 50.00f, 7.00f);
                plr->RemoveAurasDueToSpell(48018);
            }
            m_knockbackCheck = false;
        } else m_knockback -= diff;
    }
}
Beispiel #3
0
BOOL CMAPIAppointment::GetStartTime(CString& strStartTime, LPCTSTR szFormat)
{
	SYSTEMTIME tm;
	if(GetStartTime(tm)) 
	{
		TCHAR szTime[256];
		if(!szFormat) szFormat=_T("MM/dd/yyyy hh:mm:ss tt");
		GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &tm, szFormat, szTime, 256);
		GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &tm, szTime, szTime, 256);
		strStartTime=szTime;
		return TRUE;
	}
	return FALSE;
}
Beispiel #4
0
void BattlegroundNA::InitializeObjects()
{
    ObjectGUIDsByType.resize(BG_NA_OBJECT_MAX);
    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS)    // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }
    }

    for (uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_4; ++i)
        SpawnGameObject(i, RESPAWN_IMMEDIATELY);
}
Beispiel #5
0
void CheckMaxTime()
	{
	if (0 == g_ulMaxSecs.get())
		return;

	time_t Now = time(0);
	time_t ElapsedSecs = Now - GetStartTime();
	if (ElapsedSecs <= (time_t) g_ulMaxSecs.get())
		return;

	Log("Max time %s exceeded, elapsed seconds = %ul\n",
	  MaxSecsToStr(), ElapsedSecs);

	SaveCurrentAlignment();
	exit(EXIT_Success);
	}
void ThreadProc::run (void)
{

    GetStartTime ();
    SocketReBuild();
    for(;!gameOver;)
    {
        if(!IsWorkinPermit())
        {
            msleep(10);
            continue;
        }
        GoGoStatusMachineRecv();
        DelaySRTime();
        GoGoStatusMachineSend ();
        OverTimeProc ();
    }
}
Beispiel #7
0
void ReadOptionsDirectTimeRange(struct options_direct *opts,struct input *X)
{
  if(opts->t_start_flag==0)
    {
      opts->t_start = GetStartTime(X);
      opts->t_start_flag=1;
      mexWarnMsgIdAndTxt("STAToolkit:ReadOptionsTimeRange:missingParameter","Missing parameter start_time. Extracting from input: %f.\n",opts->t_start);
    }

  if(opts->t_end_flag==0)
    {
      opts->t_end = GetEndTime(X);
      opts->t_end_flag=1;
      mexWarnMsgIdAndTxt("STAToolkit:ReadOptionsTimeRange:missingParameter","Missing parameter end_time. Extracting from input: %f.\n",opts->t_end);
    }

  if((opts->t_start)>(opts->t_end))
      mexErrMsgIdAndTxt("STAToolkit:ReadOptionsTimeRange:badRange","Lower limit greater than upper limit for start_time and end_time.\n");
}
unsigned int CPhonemeTag::ComputeDataCheckSum()
{
	CRC32_t crc;
	CRC32_Init( &crc );

	// Checksum the text
	CRC32_ProcessBuffer( &crc, m_szPhoneme, Q_strlen( m_szPhoneme ) );
	int phonemeCode = GetPhonemeCode();
	CRC32_ProcessBuffer( &crc, &phonemeCode, sizeof( int ) );

	// Checksum timestamps
	float startTime = GetStartTime();
	float endTime = GetEndTime();
	CRC32_ProcessBuffer( &crc, &startTime, sizeof( float ) );
	CRC32_ProcessBuffer( &crc, &endTime, sizeof( float ) );

	CRC32_Final( &crc );

	return ( unsigned int )crc;
}
Beispiel #9
0
bool TimedObject::OverlapWith(TimedObject* other)
{
	if(other == NULL)
		return false;
	
	TimedObject *first, *second;
    
	if(GetStartTime() <= other->GetStartTime()) 
    {
		first = this;
		second = other;
	} 
    else 
    {
		first = other;
		second = this;
	}
	    
	return (first->GetEndTime() >= second->GetStartTime());
}
Beispiel #10
0
void BattlegroundDS::PostUpdateImpl(uint32 diff)
{
        if (GetStartTime() >= 75*IN_MILLISECONDS)
        {
            for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end();itr++)
            {
                Player *plr = ObjectAccessor::FindPlayer(itr->first);
                if (plr && plr->isAlive() && plr->GetPositionX() < 1260 && plr->GetPositionY() >755 && plr->GetPositionY() < 775 && plr->GetPositionZ() > 13)
                {
                    KnockBackPlayer(plr, 6.15f, 50.00f, 5.00f);
                    plr->RemoveAurasDueToSpell(48018);
                } 
                if (plr && plr->isAlive() && plr->GetPositionX() > 1330 && plr->GetPositionY() >805 && plr->GetPositionY() < 825 && plr->GetPositionZ() > 13)
                {
                    KnockBackPlayer(plr, 3.10f, 50.00f, 5.00f);
                    plr->RemoveAurasDueToSpell(48018);
                }
            }
        }

        if (getWaterFallTimer() < diff)
        {
            if (isWaterFallActive())
            {
                setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, getWaterFallTimer());
                setWaterFallActive(false);
            }
            else
            {
                setWaterFallTimer(BG_DS_WATERFALL_DURATION);
                for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
                    SpawnBGObject(i, RESPAWN_IMMEDIATELY);
                setWaterFallActive(true);
            }
        }
        else
            setWaterFallTimer(getWaterFallTimer() - diff);
}
void UMovieSceneSubSection::TrimSection( float TrimTime, bool bTrimLeft )
{
	if ( !IsTimeWithinSection( TrimTime ) )
	{
		return;
	}

	float InitialStartTime = GetStartTime();
	float InitialStartOffset = StartOffset;

	UMovieSceneSection::TrimSection( TrimTime, bTrimLeft );

	// If trimming off the left, set the offset of the shot
	if ( bTrimLeft )
	{
		float NewStartOffset = ( TrimTime - InitialStartTime ) / TimeScale;
		NewStartOffset += InitialStartOffset;

		// Ensure start offset is not less than 0
		StartOffset = FMath::Max( NewStartOffset, 0.f );
	}
}
//---------------------------------------------------------------------------
satpassdialog::satpassdialog(PList *_satList, QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::satpassdialog)
{
 TSat *sat;
 int i, flags;
 double daynum = GetStartTime(QDateTime::currentDateTime().toUTC());;

    m_ui->setupUi(this);
    setLayout(m_ui->gridLayout);

    mw = (MainWindow *) parent;
    satList = _satList;

    flags = 0;
    for(i=0; i<satList->Count; i++) {
        sat = (TSat *) satList->ItemAt(i);

        sat->daynum = daynum;
        sat->Calc();
        if(sat->IsGeostationary() || sat->Decayed(0))
            continue;

        m_ui->satListWidget->addItem(sat->name);

        flags |= sat->isActive() ? 1:0;
    }

    m_ui->activeSatBtn->setVisible(flags ? true:false);
    m_ui->dateEdit->setDate(QDate::currentDate());

    if(flags)
        on_activeSatBtn_clicked();
    else if(m_ui->satListWidget->count())
        on_satListWidget_currentItemChanged(m_ui->satListWidget->item(0), NULL);
    else
        QMessageBox::critical(this, "No satellites found!", "Click menu Satellite->Keplerian elements to download.");
}
Beispiel #13
0
bool C4TableGraph::DumpToFile(const StdStrBuf &rszFilename,
                              bool fAppend) const {
  assert(!!rszFilename);
  // nothing to write?
  if (!fWrapped && !iBackLogPos) return false;
  // try append if desired; create if unsuccessful
  CStdFile out;
  if (fAppend)
    if (!out.Append(rszFilename.getData())) fAppend = false;
  if (!fAppend) {
    if (!out.Create(rszFilename.getData())) return false;
    // print header
    out.WriteString("t\tv\n\r");
  }
  // write out current timeframe
  int iEndTime = GetEndTime();
  StdStrBuf buf;
  for (int iWriteTime = GetStartTime(); iWriteTime < iEndTime; ++iWriteTime) {
    buf.Format("%d\t%d\n\r", (int)iWriteTime, (int)GetValue(iWriteTime));
    out.WriteString(buf.getData());
  }
  return true;
}
UMovieSceneSection* UMovieSceneSubSection::SplitSection( float SplitTime )
{
	if ( !IsTimeWithinSection( SplitTime ) )
	{
		return nullptr;
	}

	float InitialStartTime = GetStartTime();
	float InitialStartOffset = StartOffset;
	float NewStartOffset = ( SplitTime - InitialStartTime ) / TimeScale;
	NewStartOffset += InitialStartOffset;

	// Ensure start offset is not less than 0
	NewStartOffset = FMath::Max( NewStartOffset, 0.f );

	UMovieSceneSubSection* NewSection = Cast<UMovieSceneSubSection>( UMovieSceneSection::SplitSection( SplitTime ) );
	if ( NewSection )
	{
		NewSection->StartOffset = NewStartOffset;
		return NewSection;
	}

	return nullptr;
}
void BattlegroundNA::Update(uint32 diff)
{
    Battleground::Update(diff);

    if(GetStatus() == STATUS_IN_PROGRESS)
    {
        if(GetStartTime() >= 47*MINUTE*IN_MILLISECONDS)    // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }

        if(m_uiTeleport < diff)
        {
            for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
            {
                Player* pPlayer = sObjectMgr->GetPlayer(itr->first);
                if(pPlayer && pPlayer->GetPositionZ() < 10)
                    pPlayer->TeleportTo(pPlayer->GetMapId(), 4056.513f, 2921.693f, 13.932f, pPlayer->GetOrientation(), false);
            }
            m_uiTeleport = 1000;
        } else m_uiTeleport -= diff;
    }
}
Beispiel #16
0
void BattleGround::EndBattleGround(uint32 winner)
{
    this->RemoveFromBGFreeSlotQueue();

    uint32 loser_rating = 0;
    uint32 winner_rating = 0;
    WorldPacket data;
    Player *Source = NULL;
    const char *winmsg = "";

    if(winner == ALLIANCE)
    {
        winmsg = GetMangosString(LANG_BG_A_WINS);

        PlaySoundToAll(SOUND_ALLIANCE_WINS);                // alliance wins sound

        SetWinner(WINNER_ALLIANCE);
    }
    else if(winner == HORDE)
    {
        winmsg = GetMangosString(LANG_BG_H_WINS);

        PlaySoundToAll(SOUND_HORDE_WINS);                   // horde wins sound

        SetWinner(WINNER_HORDE);
    }
    else
    {
        SetWinner(3);
    }

    SetStatus(STATUS_WAIT_LEAVE);
    m_EndTime = 0;

    for(std::map<uint64, BattleGroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
    {
        Player *plr = sObjectMgr.GetPlayer(itr->first);
        if(!plr)
        {
            sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
            continue;
        }

        // should remove spirit of redemption
        if(plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
            plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);

        if(!plr->isAlive())
        {
            plr->ResurrectPlayer(1.0f);
            plr->SpawnCorpseBones();
        }
        else
        {
            //needed cause else in av some creatures will kill the players at the end
            plr->CombatStop();
            plr->getHostileRefManager().deleteReferences();
        }

        uint32 team = itr->second.Team;
        if(!team) team = plr->GetTeam();

        if(team == winner)
        {
            if(!Source)
                Source = plr;
            RewardMark(plr,ITEM_WINNER_COUNT);
            RewardQuestComplete(plr);
        }
        else
            RewardMark(plr,ITEM_LOSER_COUNT);

        plr->CombatStopWithPets(true);

        BlockMovement(plr);

        sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
        plr->GetSession()->SendPacket(&data);

        uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID());
        sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
        plr->GetSession()->SendPacket(&data);
    }

    // inform invited players about the removal
    sBattleGroundMgr.m_BattleGroundQueues[BattleGroundMgr::BGQueueTypeId(GetTypeID())].BGEndedRemoveInvites(this);

    if(Source)
    {
        ChatHandler(Source).FillMessageData(&data, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, Source->GetGUID(), winmsg);
        SendPacketToAll(&data);
    }
}
Beispiel #17
0
bool WaveClip::ClearAndAddCutLine(double t0, double t1)
{
   if (t0 > GetEndTime() || t1 < GetStartTime())
      return true; // time out of bounds
      
   WaveClip *newClip = new WaveClip(mSequence->GetDirManager(),
                                    mSequence->GetSampleFormat(),
                                    mRate);
   double clip_t0 = t0;
   double clip_t1 = t1;
   if (clip_t0 < GetStartTime())
      clip_t0 = GetStartTime();
   if (clip_t1 > GetEndTime())
      clip_t1 = GetEndTime();

   if (!newClip->CreateFromCopy(clip_t0, clip_t1, this))
      return false;
   newClip->SetOffset(clip_t0-mOffset);

   // Sort out cutlines that belong to the new cutline
   WaveClipList::compatibility_iterator nextIt;

   for (WaveClipList::compatibility_iterator it = mCutLines.GetFirst(); it; it=nextIt)
   {
      nextIt = it->GetNext();
      WaveClip* clip = it->GetData();
      double cutlinePosition = mOffset + clip->GetOffset();
      if (cutlinePosition >= t0 && cutlinePosition <= t1)
      {
         clip->SetOffset(cutlinePosition - newClip->GetOffset() - mOffset);
         newClip->mCutLines.Append(clip);
         mCutLines.DeleteNode(it);
      } else
      if (cutlinePosition >= t1)
      {
         clip->Offset(clip_t0-clip_t1);
      }
   }
   
   // Clear actual audio data
   sampleCount s0, s1;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);
   
   if (GetSequence()->Delete(s0, s1-s0))
   {
      // Collapse envelope
      GetEnvelope()->CollapseRegion(t0, t1);
      if (t0 < GetStartTime())
         Offset(-(GetStartTime() - t0));

      MarkChanged();

      mCutLines.Append(newClip);
      return true;
   } else
   {
      delete newClip;
      return false;
   }
}
Beispiel #18
0
double NoteTrack::GetEndTime()
{
   return GetStartTime() + (mSeq ? mSeq->get_real_dur() : 0.0);
}
Beispiel #19
0
void BattlegroundDS::Update(uint32 diff)
{
    Battleground::Update(diff);

    if(GetStatus() != STATUS_IN_PROGRESS)
        return;

    if(GetStatus() == STATUS_IN_PROGRESS)
    {
        if(GetStartTime() >= 47*MINUTE*IN_MILLISECONDS)    // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }
    }
    if(getPipeKnockBackCount() < BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT)
    {
        if(getPipeKnockBackTimer() < diff)
        {
            for(uint32 i = BG_DS_NPC_PIPE_KNOCKBACK_1; i <= BG_DS_NPC_PIPE_KNOCKBACK_2; ++i)
                if(Creature* waterSpout = GetBgMap()->GetCreature(BGArrayForCreatures[i]))
                    waterSpout->CastSpell(waterSpout, BG_DS_SPELL_FLUSH, true);

            setPipeKnockBackCount(getPipeKnockBackCount() + 1);
            setPipeKnockBackTimer(BG_DS_PIPE_KNOCKBACK_DELAY);
        }
        else
            setPipeKnockBackTimer(getPipeKnockBackTimer() - diff);
    }

    //if(!m_knockback && m_teleport)
    //{
    //    if(m_teleport <= diff)
    //    {
    //        for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
    //        {
    //            Player* plr = ObjectAccessor::FindPlayer(itr->first);
    //            if(!plr)
    //                continue;

    //            if(plr->GetPositionZ() > 13.0f)
    //                HandlePlayerUnderMap(plr);
    //        }
    //        m_teleport = 5 * IN_MILLISECONDS;
    //    }
    //    else
    //        m_teleport -= diff;
    //}

    if(getWaterFallTimer() < diff)
    {
        switch(getWaterFallStatus())
        {
        case BG_DS_WATERFALL_STATUS_OFF: // Add the water
            DoorClose(BG_DS_OBJECT_WATER_2);
            setWaterFallTimer(BG_DS_WATERFALL_WARNING_DURATION);
            setWaterFallStatus(BG_DS_WATERFALL_STATUS_WARNING);
            break;
        case BG_DS_WATERFALL_STATUS_WARNING: // Active collision and start knockback timer
            if(GameObject* gob = GetBgMap()->GetGameObject(BGArrayForObjects[BG_DS_OBJECT_WATER_1]))
                gob->SetGoState(GO_STATE_READY);

            setWaterFallTimer(BG_DS_WATERFALL_DURATION);
            setWaterFallStatus(BG_DS_WATERFALL_STATUS_ON);
            setWaterFallKnockbackTimer(BG_DS_WATERFALL_KNOCKBACK_TIMER);
            break;
        case BG_DS_WATERFALL_STATUS_ON: // Remove collision and water
            // turn off collision
            if(GameObject* gob = GetBgMap()->GetGameObject(BGArrayForObjects[BG_DS_OBJECT_WATER_1]))
                gob->SetGoState(GO_STATE_ACTIVE);

            DoorOpen(BG_DS_OBJECT_WATER_2);
            setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
            setWaterFallStatus(BG_DS_WATERFALL_STATUS_OFF);
            break;
        }
    }
    else
        setWaterFallTimer(getWaterFallTimer() - diff);
}
Beispiel #20
0
void Session::handlePacket(Packet* packet)
{

    isActive=true;
    lastUpdate=GetStartTime();
    unsigned char ID=packet->buffer[0];

    if(status == STATE_CONNECTING_2 || status == STATE_CONNECTED)
    {
        packet->decode();

        if(ID>=0x80 && ID<=0x8f)
        {
            if(DATA_PACKET_4* datapk=dynamic_cast<DATA_PACKET_4*>(packet))
            {
                int SeqNum=datapk->seqNumber;
                ACKQueue.push_back(SeqNum);
                std::vector<EncapsulatedPacket> packets=datapk->packets;
                for(auto iter=packets.cbegin(); iter!=packets.cend(); iter++)
                    handleEncapsulatedPacketRoute(*iter);

            }

        }


    }
    else if(ID>0x00 && ID<0x80)
    {
        packet->decode();

        if(OPEN_CONNECTION_REQUEST_1* pk_=dynamic_cast<OPEN_CONNECTION_REQUEST_1*>(packet))
        {
            //  std::cout<<"received a OPEN_CONNECTION_REQUEST_1 packet from ("<<address<<":"<<port<<")"<<std::endl;
            OPEN_CONNECTION_REPLY_1 reply;
            reply.mtuSize=pk_->mtuSize;
            reply.serverId=Manager->getID();
            reply.encode();
            sendPacket(reply);
            status=STATE_CONNECTING_1;


        }
        else
        {

            if((status==STATE_CONNECTING_1 ))


                if(OPEN_CONNECTION_REQUEST_2* pk=dynamic_cast<OPEN_CONNECTION_REQUEST_2*>(packet) )
                {
                    id=pk->clientID;

                    if(pk->serverPort == Manager->getPort())
                    {
                        mtuSize=std::max(abs(pk->mtuSize),1464);
                        OPEN_CONNECTION_REPLY_2 replyt;
                        replyt.mtuSize=mtuSize;
                        replyt.serverId=Manager->getID();
                        replyt.clientAddress=address;
                        replyt.clientPort=port;
                        replyt.encode();
                        sendPacket(replyt);
                        status=STATE_CONNECTING_2;
                    }
                }

        }

    }

}
Beispiel #21
0
void BattleGround::EndBattleGround(uint32 winner)
{
    this->RemoveFromBGFreeSlotQueue();
    uint32 almost_winning_team = HORDE;
    uint32 loser_rating = 0;
    uint32 winner_rating = 0;
    WorldPacket data;
    Player *Source = NULL;
    const char *winmsg = "";

    if(winner == ALLIANCE)
    {
        winmsg = GetTrinityString(LANG_BG_A_WINS);

        PlaySoundToAll(SOUND_ALLIANCE_WINS);                // alliance wins sound

        SetWinner(WINNER_ALLIANCE);
    }
    else if(winner == HORDE)
    {
        winmsg = GetTrinityString(LANG_BG_H_WINS);

        PlaySoundToAll(SOUND_HORDE_WINS);                   // horde wins sound

        SetWinner(WINNER_HORDE);
    }
    else
    {
        SetWinner(3);
    }

    SetStatus(STATUS_WAIT_LEAVE);
    m_EndTime = 0;

    for(std::map<uint64, BattleGroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
    {
        Player *plr = objmgr.GetPlayer(itr->first);
        if(!plr)
        {
            sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first);
            continue;
        }

        // should remove spirit of redemption
        if(plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
            plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);

        if(!plr->isAlive())
        {
            plr->ResurrectPlayer(1.0f);
            plr->SpawnCorpseBones();
        }

        uint32 team = itr->second.Team;
        if(!team) team = plr->GetTeam();


        if(team == winner)
        {
            if(!Source)
                Source = plr;
            RewardMark(plr,ITEM_WINNER_COUNT);
            UpdatePlayerScore(plr, SCORE_BONUS_HONOR, 20);
            RewardQuest(plr);
        }
        else if(winner !=0)
        {
        RewardMark(plr,ITEM_LOSER_COUNT);
        }
    else if(winner == 0)
    {
        if(sWorld.getConfig(CONFIG_PREMATURE_BG_REWARD))    // We're feeling generous, giving rewards to people who not earned them ;)
        {    //nested ifs for the win! its boring writing that, forgive me my unfunniness
            
            if(almost_winning_team == team)                    //player's team had more points
                RewardMark(plr,ITEM_WINNER_COUNT);
            else
                RewardMark(plr,ITEM_LOSER_COUNT);            // if scores were the same, each team gets 1 mark.
        }
    }

        plr->CombatStopWithPets(true);

        BlockMovement(plr);

        sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
        plr->GetSession()->SendPacket(&data);

        uint32 bgQueueTypeId = sBattleGroundMgr.BGQueueTypeId(GetTypeID());
        sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
        plr->GetSession()->SendPacket(&data);
    }

    // inform invited players about the removal
    sBattleGroundMgr.m_BattleGroundQueues[sBattleGroundMgr.BGQueueTypeId(GetTypeID())].BGEndedRemoveInvites(this);

    if(Source)
    {
        ChatHandler(Source).FillMessageData(&data, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, Source->GetGUID(), winmsg);
        SendPacketToAll(&data);
    }
}
Beispiel #22
0
void BattleGround::EndBattleGround(uint32 winner)
{
    WorldPacket data;
    Player *Source = NULL;
    const char *winmsg = "";

    if(winner == ALLIANCE)
    {
        winmsg = GetMangosString(LANG_BG_A_WINS);

        PlaySoundToAll(SOUND_ALLIANCE_WINS);                // alliance wins sound

        SetWinner(WINNER_ALLIANCE);
    }
    else
    {
        winmsg = GetMangosString(LANG_BG_H_WINS);

        PlaySoundToAll(SOUND_HORDE_WINS);                   // horde wins sound

        SetWinner(WINNER_HORDE);
    }

    SetStatus(STATUS_WAIT_LEAVE);
    m_EndTime = 0;

    for(std::map<uint64, BattleGroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
    {
        Player *plr = objmgr.GetPlayer(itr->first);
        if(!plr)
        {
            sLog.outError("BattleGround: Player " I64FMTD " not found!", itr->first);
            continue;
        }

        if(!plr->isAlive())
        {
            plr->ResurrectPlayer(1.0f);
            plr->SpawnCorpseBones();
        }

        if(plr->GetTeam() == winner)
        {
            if(!Source)
                Source = plr;
            RewardMark(plr,ITEM_WINNER_COUNT);
            UpdatePlayerScore(plr, SCORE_BONUS_HONOR, 20);
            RewardQuest(plr);
        }
        else
        {
            RewardMark(plr,ITEM_LOSER_COUNT);
        }

        plr->CombatStopWithPets(true);

        BlockMovement(plr);

        sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
        plr->GetSession()->SendPacket(&data);

        sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattleGroundQueueIndex(m_TypeID), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
        plr->GetSession()->SendPacket(&data);
    }

    if(Source)
    {
        ChatHandler(Source).FillMessageData(&data, CHAT_MSG_BG_SYSTEM_NEUTRAL, LANG_UNIVERSAL, Source->GetGUID(), winmsg);
        SendPacketToAll(&data);
    }
}
void BattlegroundRV::Update(uint32 diff)
{
    Battleground::Update(diff);

    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS)    // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }
        // bochki
        if (!fencesopened)
        {
            if (fencestimer < diff)
            {
                fencesopened = true;
            }
            else
                fencestimer -= diff;
        }
    }

    if (getTimer() < diff)
    {
        uint32 i;
        if (GetBgMap())
            switch(getState())
            {
                case BG_RV_STATE_OPEN_FENCES:
                {
                    setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
                    setState(BG_RV_STATE_CLOSE_FIRE);
                    break;
                }
                case BG_RV_STATE_CLOSE_FIRE:

                    for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i)
                        DoorClose(i);
                    setTimer(BG_RV_FIRE_TO_PILAR_TIMER);
                    setState(BG_RV_STATE_OPEN_PILARS);
                    break;
                case BG_RV_STATE_OPEN_PILARS:
                    pillarsopened=true;
                    for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i)
                        DoorOpen(i);
                    setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
                    setState(BG_RV_STATE_OPEN_FIRE);
                    break;
                case BG_RV_STATE_OPEN_FIRE:
                    for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i)
                        DoorOpen(i);
                    setTimer(BG_RV_FIRE_TO_PILAR_TIMER);
                    setState(BG_RV_STATE_CLOSE_PILARS);
                    break;
                case BG_RV_STATE_CLOSE_PILARS:
                    pillarsopened=false;
                    uint32 i;
                    for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i)
                        DoorOpen(i);
                    setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
                    setState(BG_RV_STATE_CLOSE_FIRE);
                    break;
            }
    }
    else
        setTimer(getTimer() - diff);
}
Beispiel #24
0
void CGameTeams::OnFinish(CPlayer* Player)
{
	if (!Player || !Player->IsPlaying())
		return;
	//TODO:DDRace:btd: this ugly
	float time = (float) (Server()->Tick() - GetStartTime(Player))
			/ ((float) Server()->TickSpeed());
	if (time < 0.000001f)
		return;
	CPlayerData *pData = GameServer()->Score()->PlayerData(Player->GetCID());
	char aBuf[128];
	SetCpActive(Player, -2);
	str_format(aBuf, sizeof(aBuf),
			"%s finished in: %d minute(s) %5.2f second(s)",
			Server()->ClientName(Player->GetCID()), (int) time / 60,
			time - ((int) time / 60 * 60));
	if (g_Config.m_SvHideScore || !g_Config.m_SvSaveWorseScores)
		GameServer()->SendChatTarget(Player->GetCID(), aBuf);
	else
		GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);

	float diff = fabs(time - pData->m_BestTime);

	if (time - pData->m_BestTime < 0)
	{
		// new record \o/
		Server()->SaveDemo(Player->GetCID(), time);

		if (diff >= 60)
			str_format(aBuf, sizeof(aBuf), "New record: %d minute(s) %5.2f second(s) better.",
					(int) diff / 60, diff - ((int) diff / 60 * 60));
		else
			str_format(aBuf, sizeof(aBuf), "New record: %5.2f second(s) better.",
					diff);
		if (g_Config.m_SvHideScore || !g_Config.m_SvSaveWorseScores)
			GameServer()->SendChatTarget(Player->GetCID(), aBuf);
		else
			GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
	}
	else if (pData->m_BestTime != 0) // tee has already finished?
	{
		Server()->StopRecord(Player->GetCID());

		if (diff <= 0.005)
		{
			GameServer()->SendChatTarget(Player->GetCID(),
					"You finished with your best time.");
		}
		else
		{
			if (diff >= 60)
				str_format(aBuf, sizeof(aBuf), "%d minute(s) %5.2f second(s) worse, better luck next time.",
						(int) diff / 60, diff - ((int) diff / 60 * 60));
			else
				str_format(aBuf, sizeof(aBuf),
						"%5.2f second(s) worse, better luck next time.",
						diff);
			GameServer()->SendChatTarget(Player->GetCID(), aBuf); //this is private, sent only to the tee
		}
	}
	else
	{
		Server()->SaveDemo(Player->GetCID(), time);
	}

	bool CallSaveScore = false;
#if defined(CONF_SQL)
	CallSaveScore = g_Config.m_SvUseSQL && g_Config.m_SvSaveWorseScores;
#endif

	if (!pData->m_BestTime || time < pData->m_BestTime)
	{
		// update the score
		pData->Set(time, GetCpCurrent(Player));
		CallSaveScore = true;
	}

	if (CallSaveScore)
		if (g_Config.m_SvNamelessScore || str_comp_num(Server()->ClientName(Player->GetCID()), "nameless tee",
				12) != 0)
			GameServer()->Score()->SaveScore(Player->GetCID(), time,
					GetCpCurrent(Player));

	bool NeedToSendNewRecord = false;
	// update server best time
	if (GameServer()->m_pController->m_CurrentRecord == 0
			|| time < GameServer()->m_pController->m_CurrentRecord)
	{
		// check for nameless
		if (g_Config.m_SvNamelessScore || str_comp_num(Server()->ClientName(Player->GetCID()), "nameless tee",
				12) != 0)
		{
			GameServer()->m_pController->m_CurrentRecord = time;
			//dbg_msg("character", "Finish");
			NeedToSendNewRecord = true;
		}
	}

	SetDDRaceState(Player, DDRACE_FINISHED);
	// set player score
	if (!pData->m_CurrentTime || pData->m_CurrentTime > time)
	{
		pData->m_CurrentTime = time;
		NeedToSendNewRecord = true;
		for (int i = 0; i < MAX_CLIENTS; i++)
		{
			if (GetPlayer(i) && GetPlayer(i)->m_ClientVersion >= VERSION_DDRACE)
			{
				if (!g_Config.m_SvHideScore || i == Player->GetCID())
				{
					CNetMsg_Sv_PlayerTime Msg;
					Msg.m_Time = time * 100.0;
					Msg.m_ClientID = Player->GetCID();
					Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
				}
			}
		}
	}

	if (NeedToSendNewRecord && Player->m_ClientVersion >= VERSION_DDRACE)
	{
		for (int i = 0; i < MAX_CLIENTS; i++)
		{
			if (GameServer()->m_apPlayers[i]
					&& GameServer()->m_apPlayers[i]->m_ClientVersion >= VERSION_DDRACE)
			{
				GameServer()->SendRecord(i);
			}
		}
	}

	if (Player->m_ClientVersion >= VERSION_DDRACE)
	{
		CNetMsg_Sv_DDRaceTime Msg;
		Msg.m_Time = (int) (time * 100.0f);
		Msg.m_Check = 0;
		Msg.m_Finish = 1;

		if (pData->m_BestTime)
		{
			float Diff = (time - pData->m_BestTime) * 100;
			Msg.m_Check = (int) Diff;
		}

		Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, Player->GetCID());
	}

	int TTime = 0 - (int) time;
	if (Player->m_Score < TTime)
		Player->m_Score = TTime;

}
Beispiel #25
0
void BattleGround::EndBattleGround(Team winner)
{
    this->RemoveFromBGFreeSlotQueue();

    uint32 loser_rating = 0;
    uint32 winner_rating = 0;
    WorldPacket data;
    int32 winmsg_id = 0;

    if (winner == ALLIANCE)
    {
        winmsg_id = LANG_BG_A_WINS;

        PlaySoundToAll(SOUND_ALLIANCE_WINS);                // alliance wins sound
    }
    else if (winner == HORDE)
    {
        winmsg_id = LANG_BG_H_WINS;

        PlaySoundToAll(SOUND_HORDE_WINS);                   // horde wins sound
    }

    SetWinner(winner);

    SetStatus(STATUS_WAIT_LEAVE);
    // we must set it this way, because end time is sent in packet!
    m_EndTime = TIME_TO_AUTOREMOVE;

    for (BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
    {
        Team team = itr->second.PlayerTeam;

        if (itr->second.OfflineRemoveTime)
            continue;

        Player* plr = sObjectMgr.GetPlayer(itr->first);
        if (!plr)
        {
            sLog.outError("BattleGround:EndBattleGround %s not found!", itr->first.GetString().c_str());
            continue;
        }

        // should remove spirit of redemption
        if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
            plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);

        if (!plr->isAlive())
        {
            plr->ResurrectPlayer(1.0f);
            plr->SpawnCorpseBones();
        }
        else
        {
            // needed cause else in av some creatures will kill the players at the end
            plr->CombatStop();
            plr->getHostileRefManager().deleteReferences();
        }

        // this line is obsolete - team is set ALWAYS
        // if(!team) team = plr->GetTeam();

        if (team == winner)
        {
            RewardMark(plr, ITEM_WINNER_COUNT);
            RewardQuestComplete(plr);
        }
        else
            RewardMark(plr, ITEM_LOSER_COUNT);

        plr->CombatStopWithPets(true);

        BlockMovement(plr);

        sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
        plr->GetSession()->SendPacket(&data);

        BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID());
        sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
        plr->GetSession()->SendPacket(&data);
    }

    if (winmsg_id)
        SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL);
}
Beispiel #26
0
void BattlegroundWS::PostUpdateImpl(uint32 diff)
{
    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 27*MINUTE*IN_MILLISECONDS)
        {
            if (GetTeamScore(TEAM_ALLIANCE) == 0)
            {
                if (GetTeamScore(TEAM_HORDE) == 0)        // No one scored - result is tie
                    EndBattleground(WINNER_NONE);
                else                                 // Horde has more points and thus wins
                    EndBattleground(HORDE);
            }
            else if (GetTeamScore(TEAM_HORDE) == 0)
                EndBattleground(ALLIANCE);           // Alliance has > 0, Horde has 0, alliance wins
            else if (GetTeamScore(TEAM_HORDE) == GetTeamScore(TEAM_ALLIANCE)) // Team score equal, winner is team that scored the last flag
                EndBattleground(_lastFlagCaptureTeam);
            else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE))  // Last but not least, check who has the higher score
                EndBattleground(HORDE);
            else
                EndBattleground(ALLIANCE);
        }
        // first update needed after 1 minute of game already in progress
        else if (GetStartTime() > uint32(_minutesElapsed * MINUTE * IN_MILLISECONDS) +  3 * MINUTE * IN_MILLISECONDS)
        {
            ++_minutesElapsed;
            UpdateWorldState(BG_WS_STATE_TIMER, 25 - _minutesElapsed);
        }

        if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
        {
            _flagsTimer[TEAM_ALLIANCE] -= diff;

            if (_flagsTimer[TEAM_ALLIANCE] < 0)
            {
                _flagsTimer[TEAM_ALLIANCE] = 0;
                RespawnFlag(ALLIANCE, true);
            }
        }

        if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
        {
            _flagsDropTimer[TEAM_ALLIANCE] -= diff;

            if (_flagsDropTimer[TEAM_ALLIANCE] < 0)
            {
                _flagsDropTimer[TEAM_ALLIANCE] = 0;
                RespawnFlagAfterDrop(ALLIANCE);
                _bothFlagsKept = false;
            }
        }

        if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
        {
            _flagsTimer[TEAM_HORDE] -= diff;

            if (_flagsTimer[TEAM_HORDE] < 0)
            {
                _flagsTimer[TEAM_HORDE] = 0;
                RespawnFlag(HORDE, true);
            }
        }

        if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
        {
            _flagsDropTimer[TEAM_HORDE] -= diff;

            if (_flagsDropTimer[TEAM_HORDE] < 0)
            {
                _flagsDropTimer[TEAM_HORDE] = 0;
                RespawnFlagAfterDrop(HORDE);
                _bothFlagsKept = false;
            }
        }

        if (_bothFlagsKept)
        {
            _flagSpellForceTimer += diff;
            if (_flagDebuffState == 0 && _flagSpellForceTimer >= 10*MINUTE*IN_MILLISECONDS)  //10 minutes
            {
                if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
                    player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
                if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
                    player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
                _flagDebuffState = 1;
            }
            else if (_flagDebuffState == 1 && _flagSpellForceTimer >= 900000) //15 minutes
            {
                if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
                {
                    player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
                    player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true);
                }
                if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
                {
                    player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
                    player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true);
                }
                _flagDebuffState = 2;
            }
        }
        else
        {
            if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
            {
                player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
                player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
            }
            if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
            {
                player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
                player->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
            }

            _flagSpellForceTimer = 0; //reset timer.
            _flagDebuffState = 0;
        }
    }
}
Beispiel #27
0
void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
{
    if (GetStatus() != STATUS_WAIT_LEAVE)
        return;

    WorldPacket data;
    BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID());

    BlockMovement(plr);

    sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
    plr->GetSession()->SendPacket(&data);

    sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime());
    plr->GetSession()->SendPacket(&data);
}
Beispiel #28
0
double WaveTrack::GetOffset()
{
   return GetStartTime();
}
Beispiel #29
0
void BattlegroundTP::Update(uint32 diff)
{
    Battleground::Update(diff);

    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 25*MINUTE*IN_MILLISECONDS)
        {
            if (GetTeamScore(ALLIANCE) == 0)
            {
                if (GetTeamScore(HORDE) == 0)        // No one scored - result is tie
                    EndBattleground(NULL);
                else                                 // Horde has more points and thus wins
                    EndBattleground(HORDE);
            }

            else if (GetTeamScore(HORDE) == 0)
                EndBattleground(ALLIANCE);           // Alliance has > 0, Horde has 0, alliance wins

            else if (GetTeamScore(HORDE) == GetTeamScore(ALLIANCE)) // Team score equal, winner is team that scored the last flag
                EndBattleground(m_LastFlagCaptureTeam);

            else if (GetTeamScore(HORDE) > GetTeamScore(ALLIANCE))  // Last but not least, check who has the higher score
                EndBattleground(HORDE);
            else
                EndBattleground(ALLIANCE);
        }
        else if (GetStartTime() > uint32(m_minutesElapsed * MINUTE * IN_MILLISECONDS))
        {
            ++m_minutesElapsed;
            UpdateWorldState(BG_TP_STATE_TIMER, 25 - m_minutesElapsed);
        }

        if (m_FlagState[BG_TEAM_ALLIANCE] == BG_TP_FLAG_STATE_WAIT_RESPAWN)
        {
            m_FlagsTimer[BG_TEAM_ALLIANCE] -= diff;

            if (m_FlagsTimer[BG_TEAM_ALLIANCE] < 0)
            {
                m_FlagsTimer[BG_TEAM_ALLIANCE] = 0;
                RespawnFlag(ALLIANCE, true);
            }
        }
        if (m_FlagState[BG_TEAM_ALLIANCE] == BG_TP_FLAG_STATE_ON_GROUND)
        {
            m_FlagsDropTimer[BG_TEAM_ALLIANCE] -= diff;

            if (m_FlagsDropTimer[BG_TEAM_ALLIANCE] < 0)
            {
                m_FlagsDropTimer[BG_TEAM_ALLIANCE] = 0;
                RespawnFlagAfterDrop(ALLIANCE);
                m_BothFlagsKept = false;
            }
        }
        if (m_FlagState[BG_TEAM_HORDE] == BG_TP_FLAG_STATE_WAIT_RESPAWN)
        {
            m_FlagsTimer[BG_TEAM_HORDE] -= diff;

            if (m_FlagsTimer[BG_TEAM_HORDE] < 0)
            {
                m_FlagsTimer[BG_TEAM_HORDE] = 0;
                RespawnFlag(HORDE, true);
            }
        }
        if (m_FlagState[BG_TEAM_HORDE] == BG_TP_FLAG_STATE_ON_GROUND)
        {
            m_FlagsDropTimer[BG_TEAM_HORDE] -= diff;

            if (m_FlagsDropTimer[BG_TEAM_HORDE] < 0)
            {
                m_FlagsDropTimer[BG_TEAM_HORDE] = 0;
                RespawnFlagAfterDrop(HORDE);
                m_BothFlagsKept = false;
            }
        }
        if (m_BothFlagsKept)
        {
          m_FlagSpellForceTimer += diff;
          if (m_FlagDebuffState == 0 && m_FlagSpellForceTimer >= 600000)  //10 minutes
          {
            if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[0]))
              plr->CastSpell(plr, TP_SPELL_FOCUSED_ASSAULT, true);
            if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[1]))
              plr->CastSpell(plr, TP_SPELL_FOCUSED_ASSAULT, true);
            m_FlagDebuffState = 1;
          }
          else if (m_FlagDebuffState == 1 && m_FlagSpellForceTimer >= 900000) //15 minutes
          {
            if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[0]))
            {
              plr->RemoveAurasDueToSpell(TP_SPELL_FOCUSED_ASSAULT);
              plr->CastSpell(plr, TP_SPELL_BRUTAL_ASSAULT, true);
            }
            if (Player * plr = sObjectMgr->GetPlayer(m_FlagKeepers[1]))
            {
              plr->RemoveAurasDueToSpell(TP_SPELL_FOCUSED_ASSAULT);
              plr->CastSpell(plr, TP_SPELL_BRUTAL_ASSAULT, true);
            }
            m_FlagDebuffState = 2;
          }
        }
        else
        {
          m_FlagSpellForceTimer = 0; //reset timer.
          m_FlagDebuffState = 0;
        }
    }
}
Beispiel #30
0
void BattlegroundRV::Update(uint32 diff)
{
    Battleground::Update(diff);

    if (GetStatus() == STATUS_IN_PROGRESS)
    {
        if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS)    // after 47 minutes without one team losing, the arena closes with no winner and no rating change
        {
            UpdateArenaWorldState();
            CheckArenaAfterTimerConditions();
        }
        // teleport buggers
        if(m_uiTeleport < diff)
        {
            for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
            {
                Player * plr = sObjectMgr->GetPlayer(itr->first);
                if (plr && plr->GetPositionZ() < 27)
                    plr->TeleportTo(plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), 29, plr->GetOrientation(), false);
                if (plr && plr->GetPositionZ() < 27)
                    plr->TeleportTo(plr->GetMapId(), plr->GetPositionX(), plr->GetPositionY(), 29, plr->GetOrientation(), false);
            }
            m_uiTeleport = 1000;
        }
        else
            m_uiTeleport -= diff;
    }

    if (getTimer() < diff)
    {
        uint32 i;
        switch(getState())
        {
        case BG_RV_STATE_OPEN_FENCES:
        {
            setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
            setState(BG_RV_STATE_CLOSE_FIRE);
            break;
        }
        case BG_RV_STATE_CLOSE_FIRE:
            //uint32 i;
            for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i)
                DoorOpen(i);
            setTimer(BG_RV_FIRE_TO_PILAR_TIMER);
            setState(BG_RV_STATE_OPEN_PILARS);
            break;
        case BG_RV_STATE_OPEN_PILARS:
            for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i)
                DoorOpen(i);
            setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
            setState(BG_RV_STATE_OPEN_FIRE);
            break;
        case BG_RV_STATE_OPEN_FIRE:
            for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i)
                DoorOpen(i);
            setTimer(BG_RV_FIRE_TO_PILAR_TIMER);
            setState(BG_RV_STATE_CLOSE_PILARS);
            break;
        case BG_RV_STATE_CLOSE_PILARS:
            //uint32 i;
            for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i)
                DoorOpen(i);
            setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
            setState(BG_RV_STATE_CLOSE_FIRE);
            break;
        }
    }
    else
        setTimer(getTimer() - diff);
}