示例#1
0
void Arena::OnStart()
{
	/* remove arena readyness buff */
	for(uint32 i = 0; i < 2; ++i) {
		for(set<Player*  >::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) {
			Player* plr = *itr;
			plr->RemoveAura(ARENA_PREPARATION);
		}
	}

	/* open gates */
	for(set< GameObject* >::iterator itr = m_gates.begin(); itr != m_gates.end(); ++itr)
	{
		(*itr)->SetUInt32Value(GAMEOBJECT_FLAGS, 64);
		(*itr)->SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_STATE, 0);
	}

	m_started = true;

	/* Incase all players left */
	UpdatePlayerCounts();

	// soundz!
	PlaySoundToAll(SOUND_BATTLEGROUND_BEGIN);

	sEventMgr.RemoveEvents(this, EVENT_ARENA_SHADOW_SIGHT);
	sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::HookOnShadowSight, EVENT_ARENA_SHADOW_SIGHT, 90000, 1,0);
}
示例#2
0
bool EyeOfTheStorm::GivePoints(uint32 team, uint32 points)
{
    if(m_ended || !m_started)
        return false;

    //printf("EOTS: Give team %u %u points.\n", team, points);

    m_points[team] += points;

    if( m_points[team] >= m_resourceRewards[team] )
    {
        m_resourceRewards[team] += m_resToGainBH;

        for(set<Player*  >::iterator itx = m_players[team].begin(); itx != m_players[team].end(); itx++)
        {
            Player* plr = (*itx);
            if(!plr) continue;
            (*itx)->m_bgScore.BonusHonor += m_bonusHonor;
            HonorHandler::AddHonorPointsToPlayer( plr, m_bonusHonor );
        }
    }

    if( m_points[team] >= 1600 )
    {
        m_points[team] = 1600;
        m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_ALLIANCE_VICTORYPOINTS + team, m_points[team] );

        m_ended = true;
        m_losingteam = (team) ? 0 : 1;
        m_nextPvPUpdateTime = 0;

        sEventMgr.RemoveEvents(this);
        sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);
        SendChatMessage( CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "|cffffff00This battleground will close in 2 minutes.");

        /* add the marks of honor to all players */
        m_mainLock.Acquire();

        for(uint32 i = 0; i < 2; i++)
        {
            for(set<Player*  >::iterator itr = m_players[i].begin(); itr != m_players[i].end(); itr++)
            {
                (*itr)->Root();

                if( (*itr)->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_AFK) )
                    continue;

                // create eye of the storm mark of honor
                uint32 item_count = (i == m_losingteam) ? 1 : 3;

                if( i != m_losingteam )
                {
                    (*itr)->m_bgScore.BonusHonor += 2*m_bonusHonor;
                    HonorHandler::AddHonorPointsToPlayer( (*itr), 2*m_bonusHonor );
                    if((*itr)->fromrandombg)
                    {
                        (*itr)->m_honorToday += (*itr)->GenerateRBGReward((*itr)->getLevel(),5);
                        HonorHandler::RecalculateHonorFields((*itr));
                        (*itr)->fromrandombg = false;
                    }
                }
                else
                {
                    (*itr)->m_bgScore.BonusHonor += m_bonusHonor;
                    HonorHandler::AddHonorPointsToPlayer( (*itr), m_bonusHonor );
                    uint32 diff = abs((int32)(m_points[i] - m_points[i ? 0 : 1]));
                    (*itr)->GetAchievementInterface()->HandleAchievementCriteriaWinBattleground( m_mapMgr->GetMapId(), diff, ((uint32)UNIXTIME - m_startTime) / 1000, TO_CBATTLEGROUND(this));
                    if((*itr)->fromrandombg)
                    {
                        Player * p = (*itr);
                        p->AddArenaPoints(p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),25) : p->GenerateRBGReward(p->getLevel(),0));
                        p->m_honorToday += p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),30) : p->GenerateRBGReward(p->getLevel(),15);
                        HonorHandler::RecalculateHonorFields(p);
                        p->randombgwinner = true;
                        p->fromrandombg = false;
                    }
                }

                Item* pReward;
                SlotResult res;
                if( ( pReward = (*itr)->GetItemInterface()->FindItemLessMax(EOTS_MARK_ID, item_count, false) ) == NULL )
                {
                    res = (*itr)->GetItemInterface()->FindFreeInventorySlot( ItemPrototypeStorage.LookupEntry(EOTS_MARK_ID) );
                    if( !res.Result )
                    {
                        (*itr)->BroadcastMessage("Could not add EOTS mark. Make sure you have room in your inventory.");
                        continue;
                    }

                    pReward = objmgr.CreateItem(EOTS_MARK_ID, (*itr));
                    pReward->SetUInt32Value(ITEM_FIELD_STACK_COUNT, item_count);
                    pReward->m_isDirty = true;
                    if( !(*itr)->GetItemInterface()->SafeAddItem(pReward, res.ContainerSlot, res.Slot) )
                    {
                        if( !(*itr)->GetItemInterface()->AddItemToFreeSlot(pReward) )
                        {
                            pReward->DeleteMe();
                            pReward = NULLGOB;
                        }
                    }
                    (*itr)->GetSession()->SendItemPushResult(pReward,true,false,true,false,res.ContainerSlot,res.Slot, item_count);
                }
                else
                {
                    pReward->m_isDirty = true;
                    pReward->ModUnsigned32Value(ITEM_FIELD_STACK_COUNT, item_count);

                    res.ContainerSlot = (*itr)->GetItemInterface()->GetBagSlotByGuid(pReward->GetGUID());
                    res.Slot = -1;
                    (*itr)->GetSession()->SendItemPushResult(pReward,true,false,true,true,res.ContainerSlot,res.Slot, item_count);
                }
            }
        }
        UpdatePvPData();
        m_mainLock.Release();
        return true;
    }

    m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
    return false;
}
示例#3
0
void Arena::Finish()
{
	m_ended = true;
	ArenaTeam * teams[2] = {NULL, NULL};
	if(rated_match)
	{
		teams[0] = objmgr.GetArenaTeamById(m_teams[0]);
		teams[1] = objmgr.GetArenaTeamById(m_teams[1]);
	}
	/* update arena team stats */
	if(rated_match && teams[0] && teams[1])
	{
		for (uint32 i = 0; i < 2; ++i) {
			uint32 j = i ? 0 : 1; // opposing side
			bool outcome = (i != m_losingteam);
			if (outcome) {
				teams[i]->m_stat_gameswonseason++;
				teams[i]->m_stat_gameswonweek++;
			}

			m_deltaRating[i] = CalcDeltaRating(teams[i]->m_stat_rating, teams[j]->m_stat_rating, outcome);
			teams[i]->m_stat_rating += m_deltaRating[i];
			if ((int32)teams[i]->m_stat_rating < 0) teams[i]->m_stat_rating = 0;

			for(set<uint32>::iterator itr = m_players2[i].begin(); itr != m_players2[i].end(); ++itr)
			{
				PlayerInfo * info = objmgr.GetPlayerInfo(*itr);
				if (info)
				{
					ArenaTeamMember * tp = teams[i]->GetMember(info);
					if(tp != NULL)
					{
						tp->PersonalRating += CalcDeltaRating(tp->PersonalRating, teams[j]->m_stat_rating, outcome);

						if ((int32)tp->PersonalRating < 0)
							tp->PersonalRating = 0;

						if(outcome)
						{
							tp->Won_ThisWeek++;
							tp->Won_ThisSeason++;
						}
					}
				}
			}

			teams[i]->SaveToDB();
			// send arena team stats update
			WorldPacket data(256);
			teams[i]->Stat(data);
			teams[i]->SendPacket(&data);
		}
		objmgr.UpdateArenaTeamRankings();
	}

	m_nextPvPUpdateTime = 0;
	UpdatePvPData();
	PlaySoundToAll(m_losingteam ? SOUND_ALLIANCEWINS : SOUND_HORDEWINS);

	sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE);
	sEventMgr.RemoveEvents(this, EVENT_ARENA_SHADOW_SIGHT);
	sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);

	for(int i = 0; i < 2; i++)
	{
		bool victorious = (i != m_losingteam);
		set<Player*  >::iterator itr = m_players[i].begin();
		for(; itr != m_players[i].end(); itr++)
		{
			Player* plr = (Player* )(*itr);
			plr->Root();

			if( plr->m_bgScore.DamageDone == 0 && plr->m_bgScore.HealingDone == 0 )
				continue;

			sHookInterface.OnArenaFinish(plr, m_arenateamtype, plr->m_playerInfo->arenaTeam[m_arenateamtype], victorious, rated_match);
		}
	}
}
void ArathiBasin::EventUpdateResources(uint32 Team)
{
	static uint32 resource_fields[2] = { WORLDSTATE_AB_ALLIANCE_RESOURCES, WORLDSTATE_AB_HORDE_RESOURCES };

	uint32 current_resources = m_resources[Team];
	uint32 current_bases = m_capturedBases[Team];

	if(current_bases>5)
		current_bases=5;

	// figure out how much resources we have to add to that team based on the number of captured bases.
	current_resources += (PointBonusPerUpdate[current_bases]);

	// did it change?
	if(current_resources == m_resources[Team])
		return;

	m_mainLock.Acquire();

	// check for overflow
	if(current_resources > RESOURCES_WINVAL)
		current_resources = RESOURCES_WINVAL;

	m_resources[Team] = current_resources;
	if((current_resources - m_lastHonorGainResources[Team]) >= resourcesToGainBH)
	{
		for(set<PlayerPointer  >::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); ++itr)
		{
			(*itr)->m_bgScore.BonusHonor += resHonorTable[m_lgroup];
			HonorHandler::AddHonorPointsToPlayer((*itr), resHonorTable[m_lgroup]);
		}
	}

	// update the world states
	m_mapMgr->GetStateManager().UpdateWorldState(resource_fields[Team], current_resources);

	if(current_resources >= RESOURCES_WARNING_THRESHOLD && !m_nearingVictory[Team])
	{
		m_nearingVictory[Team] = true;
		SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, (uint64)0, "The %s has gathered %u resources and is nearing victory!", Team ? "Horde" : "Alliance", current_resources);
		uint32 sound = SOUND_ALLIANCE_BGALMOSTEND - Team;
		PlaySoundToAll(sound);
	}

	// check for winning condition
	if(current_resources == RESOURCES_WINVAL)
	{
		m_ended = true;
		m_losingteam = (Team) ? 0 : 1;
		m_nextPvPUpdateTime = 0;

		sEventMgr.RemoveEvents(shared_from_this());
		sEventMgr.AddEvent(TO_CBATTLEGROUND(shared_from_this()), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);

		/* add the marks of honor to all players */
		SpellEntry * winner_spell = dbcSpell.LookupEntry(24953);
		SpellEntry * loser_spell = dbcSpell.LookupEntry(24952);
		for(uint32 i = 0; i < 2; ++i)
		{
			for(set<PlayerPointer  >::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
			{
				(*itr)->Root();

				if( (*itr)->HasFlag(PLAYER_FLAGS, 0x2) )
					continue;

				if(i == m_losingteam)
					(*itr)->CastSpell((*itr), loser_spell, true);
				else
				{
					(*itr)->CastSpell((*itr), winner_spell, true);
					(*itr)->m_bgScore.BonusHonor += winHonorTable[m_lgroup];
					HonorHandler::AddHonorPointsToPlayer((*itr), winHonorTable[m_lgroup]);
					uint32 diff = abs((int32)(m_resources[i] - m_resources[i ? 0 : 1]));
					(*itr)->GetAchievementInterface()->HandleAchievementCriteriaWinBattleground( m_mapMgr->GetMapId(), diff, ((uint32)UNIXTIME - m_startTime) / 1000, TO_CBATTLEGROUND(shared_from_this()));
				}
			}
		}
	}

	UpdatePvPData();
	m_mainLock.Release();
}
示例#5
0
void ArathiBasin::EventUpdateResources(uint32 Team)
{
	static uint32 resource_fields[2] = { WORLDSTATE_AB_ALLIANCE_RESOURCES, WORLDSTATE_AB_HORDE_RESOURCES };

	uint32 current_resources = m_resources[Team];
	uint32 current_bases = m_capturedBases[Team];

	if(current_bases>5)
		current_bases=5;

	// figure out how much resources we have to add to that team based on the number of captured bases.
	current_resources += (PointBonusPerUpdate[current_bases]);

	// did it change?
	if(current_resources == m_resources[Team])
		return;

	m_mainLock.Acquire();

	// check for overflow
	if(current_resources > RESOURCES_WINVAL)
		current_resources = RESOURCES_WINVAL;

	m_resources[Team] = current_resources;
	if((current_resources - m_lastHonorGainResources[Team]) >= m_resToGainBH)
	{
		m_lastHonorGainResources[Team] += m_resToGainBH;
		for(set< Player* >::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); itr++)
		{
			(*itr)->m_bgScore.BonusHonor += m_bonusHonor;
			HonorHandler::AddHonorPointsToPlayer((*itr), m_bonusHonor);
		}
	}

	// update the world states
	m_mapMgr->GetStateManager().UpdateWorldState(resource_fields[Team], current_resources);

	if(current_resources >= RESOURCES_WARNING_THRESHOLD && !m_nearingVictory[Team])
	{
		m_nearingVictory[Team] = true;
		SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, (uint64)0, "The %s has gathered %u resources and is nearing victory!", Team ? "Horde" : "Alliance", current_resources);
		uint32 sound = SOUND_ALLIANCE_BGALMOSTEND - Team;
		PlaySoundToAll(sound);
	}

	// check for winning condition
	if(current_resources == RESOURCES_WINVAL)
	{
		m_ended = true;
		m_losingteam = (Team) ? 0 : 1;
		m_nextPvPUpdateTime = 0;

		sEventMgr.RemoveEvents(this);
		sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);
		SendChatMessage( CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "|cffffff00This battleground will close in 2 minutes.");

		for(uint32 i = 0; i < 2; i++)
		{
			for(set<Player*  >::iterator itr = m_players[i].begin(); itr != m_players[i].end(); itr++)
			{
				(*itr)->Root();

				if( (*itr)->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_AFK) )
					continue;

				if(i == m_losingteam)
				{
					(*itr)->m_bgScore.BonusHonor += m_bonusHonor;
					HonorHandler::AddHonorPointsToPlayer((*itr), m_bonusHonor);
					if((*itr)->fromrandombg)
					{
						(*itr)->m_honorToday += (*itr)->GenerateRBGReward((*itr)->getLevel(),5);
						HonorHandler::RecalculateHonorFields((*itr));
						(*itr)->fromrandombg = false;
					}
				}
				else
				{
					(*itr)->m_bgScore.BonusHonor += 2*m_bonusHonor;
					HonorHandler::AddHonorPointsToPlayer((*itr), 2*m_bonusHonor);
					uint32 diff = abs((int32)(m_resources[i] - m_resources[i ? 0 : 1]));
					(*itr)->GetAchievementInterface()->HandleAchievementCriteriaWinBattleground( m_mapMgr->GetMapId(), diff, ((uint32)UNIXTIME - m_startTime) / 1000, TO_CBATTLEGROUND(this));
					if((*itr)->fromrandombg)
					{
						Player * p = (*itr);
						p->AddArenaPoints(p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),25) : p->GenerateRBGReward(p->getLevel(),0));
						p->m_honorToday += p->randombgwinner == false ? p->GenerateRBGReward(p->getLevel(),30) : p->GenerateRBGReward(p->getLevel(),15);
						HonorHandler::RecalculateHonorFields(p);
						p->randombgwinner = true;
						p->fromrandombg = false;
					}
				}
			}
		}
	}

	UpdatePvPData();
	m_mainLock.Release();
}