Beispiel #1
0
void IsleOfConquest::HookOnPlayerKill(Player* plr, Player* pVictim)
{
	plr->AddHonor(20);
	plr->m_bgScore.KillingBlows++;
	UpdatePvPData();
}
Beispiel #2
0
void CBattleground::PortPlayer(Player * plr, bool skip_teleport /* = false*/)
{
	m_mainLock.Acquire();
	if(m_ended)
	{
		sChatHandler.SystemMessage(plr->GetSession(), "You cannot join this battleground as it has already ended.");
		BattlegroundManager.SendBattlefieldStatus(plr, 0, 0, 0, 0, 0,0);
		plr->m_pendingBattleground = 0;
		m_mainLock.Release();
		return;
	}

	m_pendPlayers[plr->m_bgTeam].erase(plr->GetLowGUID());
	if(m_players[plr->m_bgTeam].find(plr) != m_players[plr->m_bgTeam].end())
	{
		m_mainLock.Release();
		return;
	}

	if( plr->m_bg != NULL )
		plr->m_bg->RemovePlayer(plr, true);		// don't bother porting them out, we're about to port them anyway

	if( plr->m_bgIsQueued )
	{
		BattlegroundManager.RemovePlayerFromQueues(plr);
		if( plr->GetGroup() != NULL && plr->GetGroup()->m_isqueued )
			BattlegroundManager.RemoveGroupFromQueues(plr->GetGroup());
	}

	plr->SetTeam(plr->m_bgTeam);
	plr->m_bgIsQueued = false;
	if( !plr->m_isGmInvisible )
	{
		WorldPacket data(SMSG_BATTLEGROUND_PLAYER_JOINED, 8);
		data << plr->GetGUID();
		DistributePacketToAll(&data);
	}

	m_players[plr->m_bgTeam].insert(plr);

	/* remove from any auto queue remove events */
	sEventMgr.RemoveEvents(plr, EVENT_BATTLEGROUND_QUEUE_UPDATE);

	if( !skip_teleport )
	{
		if( plr->IsInWorld() )
			plr->RemoveFromWorld();
	}

	plr->m_pendingBattleground = 0;
	plr->m_bg = this;
	
	if(!plr->IsPvPFlagged())
		plr->SetPvPFlag();

	/* Reset the score */
	memset(&plr->m_bgScore, 0, sizeof(BGScore));

	/* update pvp data */
	UpdatePvPData();

	/* add the player to the group */
	if(plr->GetGroup() && !Rated())
	{
		// remove them from their group
		plr->GetGroup()->RemovePlayer( plr->m_playerInfo );
	}

	if(!m_countdownStage)
	{
		m_countdownStage = 1;
		sEventMgr.AddEvent(this, &CBattleground::EventCountdown, EVENT_BATTLEGROUND_COUNTDOWN, 30000, 0,0);
		sEventMgr.ModifyEventTimeLeft(this, EVENT_BATTLEGROUND_COUNTDOWN, 10000);
	}

	sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE);
	OnAddPlayer(plr);

	if(!skip_teleport)
	{
		/* This is where we actually teleport the player to the battleground. */	
		plr->SafeTeleport(m_mapMgr,GetStartingCoords(plr->m_bgTeam));
		BattlegroundManager.SendBattlefieldStatus(plr, 3, m_type, m_id, (uint32)UNIXTIME - m_startTime, m_mapMgr->GetMapId(),Rated());	// Elapsed time is the last argument
	}

	m_mainLock.Release();
}
Beispiel #3
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]) >= RESOURCES_TO_GAIN_BH)
	{
		for(set<Player*>::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); ++itr)
			(*itr)->m_bgScore.BonusHonor += BASE_BH_GAIN;
	}

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

	if( current_resources >= m_reprewards[Team] )
	{
		for(set<Player*>::iterator itx = m_players[Team].begin(); itx != m_players[Team].end(); itx++)
		{
			Player * plr = (*itx);
			if(!plr) continue;

			HonorHandler::AddHonorPointsToPlayer( plr, 20 );
		}

		m_reprewards[Team] += 330;
	}

	if(current_resources >= RESOURCES_WARNING_THRESHOLD && !m_nearingVictory[Team])
	{
		m_nearingVictory[Team] = true;
		SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_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(((CBattleground*)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<Player*>::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);
					HonorHandler::AddHonorPointsToPlayer( (*itr), 20 );
				}
			}
		}
	}

	UpdatePvPData();
	m_mainLock.Release();
}
Beispiel #4
0
void ArathiBasin::AssaultControlPoint(Player* pPlayer, uint32 Id)
{
#if defined(BG_ANTI_CHEAT) && !defined(_DEBUG)
	if(!m_started)
	{
		SendChatMessage(CHAT_MSG_BG_SYSTEM_NEUTRAL, pPlayer->GetGUID(), "%s has been removed from the game for cheating.", pPlayer->GetName());
		pPlayer->SoftDisconnect();
		return;
	}
#endif

	bool isVirgin = false;

	uint32 Team = pPlayer->m_bgTeam;
	uint32 Owner;

	if(m_basesOwnedBy[Id]==-1 && m_basesAssaultedBy[Id]==-1)
	{
		isVirgin = true;
		// omgwtfbbq our flag is a virgin?
		m_mapMgr->GetStateManager().UpdateWorldState(NeutralFields[Id], 0);
	}

	if(m_basesOwnedBy[Id] != -1)
	{
		Owner = m_basesOwnedBy[Id];

		// set it to uncontrolled for now
		m_basesOwnedBy[Id] = -1;

		// this control point just got taken over by someone! oh noes!
		if( m_spiritGuides[Id] != NULL )
		{
			map<Creature*,set<uint32> >::iterator itr = m_resurrectMap.find(m_spiritGuides[Id]);
			if( itr != m_resurrectMap.end() )
			{
				for( set<uint32>::iterator it2 = itr->second.begin(); it2 != itr->second.end(); it2++ )
				{
					Player* r_plr = m_mapMgr->GetPlayer( *it2 );
					if( r_plr != NULL && r_plr->isDead() )
					{
						HookHandleRepop( r_plr );
						QueueAtNearestSpiritGuide(r_plr, itr->first);
					}
				}
			}
			m_resurrectMap.erase( itr );
			m_spiritGuides[Id]->Despawn( 0, 0 );
			m_spiritGuides[Id] = NULLCREATURE;
		}

		// detract one from the teams controlled points
		m_capturedBases[Owner] -= 1;
		m_mapMgr->GetStateManager().UpdateWorldState(Owner ? WORLDSTATE_AB_HORDE_CAPTUREBASE : WORLDSTATE_AB_ALLIANCE_CAPTUREBASE, m_capturedBases[Owner]);

		// reset the world states
		m_mapMgr->GetStateManager().UpdateWorldState(OwnedFields[Id][Owner], 0);

		// modify the resource update time period
		if(m_capturedBases[Owner]==0)
			event_RemoveEvents(EVENT_AB_RESOURCES_UPDATE_TEAM_0+Owner);
		else
			event_ModifyTime(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Owner, ResourceUpdateIntervals[m_capturedBases[Owner]]);
	}

	// Contested Flag, not ours, and is not virgin
	if( !isVirgin && m_basesLastOwnedBy[Id] == int32(Team) && m_basesOwnedBy[Id] == -1 )
	{
		m_mapMgr->GetStateManager().UpdateWorldState(AssaultFields[Id][Team ? 0 : 1], 0);
		event_RemoveEvents(EVENT_AB_CAPTURE_CP_1 + Id);
		SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, pPlayer->GetGUID(), "$N has defended the %s!", ControlPointNames[Id]);
		m_basesAssaultedBy[Id] = Team;
		CaptureControlPoint( Id, Team );
		return;
	}

	// n***a stole my flag!
	if(m_basesAssaultedBy[Id] != -1)
	{
		Owner = m_basesAssaultedBy[Id];

		// woah! vehicle hijack!
		m_basesAssaultedBy[Id] = Team;
		m_mapMgr->GetStateManager().UpdateWorldState(AssaultFields[Id][Owner], 0);

		// make sure the event does not trigger
		sEventMgr.RemoveEvents(this, EVENT_AB_CAPTURE_CP_1 + Id);

		// no need to remove the spawn, SpawnControlPoint will do this.
	}

	m_basesAssaultedBy[Id] = Team;

	// spawn the new control point gameobject
	SpawnControlPoint(Id, Team ? AB_SPAWN_TYPE_HORDE_ASSAULT : AB_SPAWN_TYPE_ALLIANCE_ASSAULT);

	// send out the chat message and sound
	SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, pPlayer->GetGUID(), "$N claims the %s! If left unchallenged, the %s will control it in 1 minute!", ControlPointNames[Id],
		Team ? "Horde" : "Alliance");

	// guessed
	PlaySoundToAll(Team ? SOUND_ALLIANCE_CAPTURE : SOUND_HORDE_CAPTURE);

	// update the client's map with the new assaulting field
	m_mapMgr->GetStateManager().UpdateWorldState(AssaultFields[Id][Team], 1);

	// create the 60 second event.
	sEventMgr.AddEvent(TO_ARATHIBASIN(this), &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, 60000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

	// update players info
	pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASE_ASSAULTED]++;
	UpdatePvPData();
}
Beispiel #5
0
void IsleOfConquest::HookOnHK(Player* plr)
{
    plr->m_bgScore.HonorableKills++;
    UpdatePvPData();
}
Beispiel #6
0
void ArathiBasin::EventUpdateResources(uint32 Team)
{
    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;

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

    m_resources[Team] = current_resources;
    if((current_resources - m_lastRepGainResources[Team]) >= resourcesToGainBR)
    {
        m_mainLock.Acquire();
        for(set<Player*>::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); ++itr)
        {
            uint32 fact = (*itr)->IsTeamHorde() ? 510 : 509; //The Defilers : The League of Arathor
            (*itr)->ModStanding(fact, 10);
        }
        m_mainLock.Release();
        m_lastRepGainResources[Team] += resourcesToGainBR;
    }

    if((current_resources - m_lastHonorGainResources[Team]) >= resourcesToGainBH)
    {
        uint32 honorToAdd = m_honorPerKill;
        m_mainLock.Acquire();
        for(set<Player*>::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); ++itr)
        {
            (*itr)->m_bgScore.BonusHonor += honorToAdd;
            HonorHandler::AddHonorPointsToPlayer((*itr), honorToAdd);
        }

        UpdatePvPData();
        m_mainLock.Release();
        m_lastHonorGainResources[Team] += resourcesToGainBH;
    }

    // update the world states
    SetWorldState(resource_fields[Team], current_resources);

    if(current_resources >= RESOURCES_WARNING_THRESHOLD && !m_nearingVictory[Team])
    {
        m_nearingVictory[Team] = true;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_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_winningteam = static_cast<uint8>(Team);
        m_nextPvPUpdateTime = 0;

        sEventMgr.RemoveEvents(this);
        sEventMgr.AddEvent(TO<CBattleground*>(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

        m_winningteam = Team;        

        AddHonorToTeam(m_winningteam, 3 * 185);

        // Winning spells for AB
        CastSpellOnTeam(m_winningteam, 43484);
        CastSpellOnTeam(m_winningteam, 69153);
        CastSpellOnTeam(m_winningteam, 69499);
        CastSpellOnTeam(m_winningteam, 69500);

        if (m_winningteam == TEAM_ALLIANCE)
        {
            AddHonorToTeam(TEAM_HORDE, 1 * 185);
            PlaySoundToAll(SOUND_ALLIANCEWINS);
        }
        else
        {
            AddHonorToTeam(TEAM_ALLIANCE, 1 * 185);
            PlaySoundToAll(SOUND_HORDEWINS);
        }

        UpdatePvPData();
    }
}
Beispiel #7
0
void ArathiBasin::AssaultControlPoint(Player* pPlayer, uint32 Id)
{
#ifdef ANTI_CHEAT
    if(!m_started)
    {
        Anticheat_Log->writefromsession(pPlayer->GetSession(), "%s tried to assault control point in arathi basin before battleground (ID %u) started.", pPlayer->GetName(), this->m_id);
        SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, pPlayer->GetGUID(), "%s will be removed from the game for cheating.", pPlayer->GetName());
        // Remove player from battleground.
        RemovePlayer(pPlayer, false);
        // Kick player from server.
        pPlayer->Kick(6000);
        return;
    }
#endif

    uint32 Team = pPlayer->m_bgTeam;
    uint32 Owner;

    pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_ASSAULTED]++;

    if(m_basesOwnedBy[Id] == -1 && m_basesAssaultedBy[Id] == -1)
    {
        // omgwtfbbq our flag is a virgin?
        SetWorldState(NeutralFields[Id], 0);
    }

    if(m_basesOwnedBy[Id] != -1)
    {
        Owner = m_basesOwnedBy[Id];

        // set it to uncontrolled for now
        m_basesOwnedBy[Id] = -1;
        m_basesLastOwnedBy[Id] = Owner;

        // this control point just got taken over by someone! oh noes!
        if(m_spiritGuides[Id] != NULL)
        {
            map<Creature*, set<uint32> >::iterator itr = m_resurrectMap.find(m_spiritGuides[Id]);
            if(itr != m_resurrectMap.end())
            {
                for(set<uint32>::iterator it2 = itr->second.begin(); it2 != itr->second.end(); ++it2)
                {
                    Player* r_plr = m_mapMgr->GetPlayer(*it2);
                    if(r_plr != NULL && r_plr->IsDead())
                        HookHandleRepop(r_plr);
                }
            }
            m_resurrectMap.erase(itr);
            m_spiritGuides[Id]->Despawn(0, 0);
            m_spiritGuides[Id] = NULL;
        }

        // detract one from the teams controlled points
        m_capturedBases[Owner] -= 1;
        SetWorldState(Owner ? WORLDSTATE_AB_HORDE_CAPTUREBASE : WORLDSTATE_AB_ALLIANCE_CAPTUREBASE, m_capturedBases[Owner]);

        // reset the world states
        SetWorldState(OwnedFields[Id][Owner], 0);

        // modify the resource update time period
        if(m_capturedBases[Owner] == 0)
            this->event_RemoveEvents(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Owner);
        else
            this->event_ModifyTime(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Owner, ResourceUpdateIntervals[m_capturedBases[Owner]]);
    }

    // n***a stole my flag!
    if(m_basesAssaultedBy[Id] != -1)
    {
        Owner = m_basesAssaultedBy[Id];

        // woah! vehicle hijack!
        m_basesAssaultedBy[Id] = -1;
        SetWorldState(AssaultFields[Id][Owner], 0);

        // make sure the event does not trigger
        sEventMgr.RemoveEvents(this, EVENT_AB_CAPTURE_CP_1 + Id);
        if(m_basesLastOwnedBy[Id] == (int32)Team)
        {
            m_basesAssaultedBy[Id] = (int32)Team;
            CaptureControlPoint(Id, Team);
            return;
        }

        // no need to remove the spawn, SpawnControlPoint will do this.
    }

    m_basesAssaultedBy[Id] = Team;

    // spawn the new control point gameobject
    SpawnControlPoint(Id, Team ? AB_SPAWN_TYPE_HORDE_ASSAULT : AB_SPAWN_TYPE_ALLIANCE_ASSAULT);

    // update the client's map with the new assaulting field
    SetWorldState(AssaultFields[Id][Team], 1);

    // Check Assault/Defense, the time of capture is not the same.
    if(DefFlag[Id][0] && !DefFlag[Id][1])
    {
        DefFlag[Id][0] = false;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N defend %s", ControlPointNames[Id]);
        sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, 1000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
        pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_CAPTURED]++;
        UpdatePvPData();
    }
    else if(!DefFlag[Id][0] && !DefFlag[Id][1])
    {
        DefFlag[Id][0] = true;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N assault %s !", ControlPointNames[Id]);
        PlaySoundToAll(Team ? 8212 : 8174);
        if(Team)
        {
            QuestLogEntry* en = pPlayer->GetQuestLogForEntry(8120);
            switch(Id)
            {
                case AB_CONTROL_POINT_MINE:
                    {
                        if(en && en->GetMobCount(0) < en->GetQuest()->required_mobcount[0])
                        {
                            en->SetMobCount(0, en->GetMobCount(0) + 1);
                            en->SendUpdateAddKill(0);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
                case AB_CONTROL_POINT_LUMBERMILL:
                    {
                        if(en && en->GetMobCount(1) < en->GetQuest()->required_mobcount[1])
                        {
                            en->SetMobCount(1, en->GetMobCount(1) + 1);
                            en->SendUpdateAddKill(1);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
                case AB_CONTROL_POINT_BLACKSMITH:
                    {
                        if(en && en->GetMobCount(2) < en->GetQuest()->required_mobcount[2])
                        {
                            en->SetMobCount(2, en->GetMobCount(2) + 1);
                            en->SendUpdateAddKill(2);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
                case AB_CONTROL_POINT_STABLE:
                    {
                        if(en && en->GetMobCount(3) < en->GetQuest()->required_mobcount[3])
                        {
                            en->SetMobCount(3, en->GetMobCount(3) + 1);
                            en->SendUpdateAddKill(3);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
            }
        }
        else
        {
            QuestLogEntry* en = pPlayer->GetQuestLogForEntry(8105);
            switch(Id)
            {
                case AB_CONTROL_POINT_MINE:
                    {
                        if(en && en->GetMobCount(0) < en->GetQuest()->required_mobcount[0])
                        {
                            en->SetMobCount(0, en->GetMobCount(0) + 1);
                            en->SendUpdateAddKill(0);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
                case AB_CONTROL_POINT_LUMBERMILL:
                    {
                        if(en && en->GetMobCount(1) < en->GetQuest()->required_mobcount[1])
                        {
                            en->SetMobCount(1, en->GetMobCount(1) + 1);
                            en->SendUpdateAddKill(1);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
                case AB_CONTROL_POINT_BLACKSMITH:
                    {
                        if(en && en->GetMobCount(2) < en->GetQuest()->required_mobcount[2])
                        {
                            en->SetMobCount(2, en->GetMobCount(2) + 1);
                            en->SendUpdateAddKill(2);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
                case AB_CONTROL_POINT_FARM:
                    {
                        if(en && en->GetMobCount(3) < en->GetQuest()->required_mobcount[3])
                        {
                            en->SetMobCount(3, en->GetMobCount(3) + 1);
                            en->SendUpdateAddKill(3);
                            en->UpdatePlayerFields();
                        }
                    }
                    break;
            }
        }
        sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, MSTIME_MINUTE, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
        pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_ASSAULTED]++;
        UpdatePvPData();
    }
    else
    {
        DefFlag[Id][0] = true;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N claims the %s! If left unchallenged, the %s will control it in 1 minute!", ControlPointNames[Id],
                        Team ? "Horde" : "Alliance");
        PlaySoundToAll(8192);
        sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, MSTIME_MINUTE, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
    }
}
Beispiel #8
0
void AlteracValley::HookOnHK(Player * plr)
{
	plr->m_bgScore.HonorableKills++;
	UpdatePvPData();
}
Beispiel #9
0
void AlteracValley::HookOnPlayerDeath(Player * plr)
{
	DecrementReinforcements(plr->GetTeam(), 1);
	plr->m_bgScore.Deaths++;
	UpdatePvPData();
}
Beispiel #10
0
void EyeOfTheStorm::HookOnAreaTrigger(Player * plr, uint32 id)
{
	int32 tid = -1;
	int32 bonusid = -1;
	switch(id)
	{
	case 4476:			// BE Tower
		tid = EOTS_TOWER_BE;
		break;
	case 4568:			// BE Tower bonus
		bonusid = EOTS_TOWER_BE;
		break;
	case 4514:			// Fel Reaver Tower
		tid = EOTS_TOWER_FELREAVER;
		break;
	case 4569:			// Fel Reaver Tower bonus
		bonusid = EOTS_TOWER_FELREAVER;
		break;
	case 4518:			// Draenei Tower
		tid = EOTS_TOWER_DRAENEI;
		break;
	case 4571:			// Draenei Tower bonus
		bonusid = EOTS_TOWER_DRAENEI;
		break;
	case 4516:			// Mage Tower
		tid = EOTS_TOWER_MAGE;
		break;
	case 4570:			// Mage Tower bonus
		bonusid = EOTS_TOWER_MAGE;
		break;
	}

	if(bonusid > -1){
		uint32 spellid=0;
		uint32 x = (uint32)bonusid;
		if(EOTSm_buffs[x] && EOTSm_buffs[x]->IsInWorld())
		{
			spellid = EOTSm_buffs[x]->GetInfo()->sound3;
			SpellEntry * sp = dbcSpell.LookupEntryForced(spellid);
			if(sp)
			{
				Spell * pSpell = SpellPool.PooledNew();
				pSpell->Init(plr, sp, true, NULL);
				SpellCastTargets targets(plr->GetGUID());
				pSpell->prepare(&targets);
			}
			EOTSm_buffs[x]->Despawn(EOTS_BUFF_RESPAWN_TIME);
		}
	}


	if( tid < 0 )
		return;

#ifdef ANTI_CHEAT
	if(!m_started)
	{
		Anticheat_Log->writefromsession(plr->GetSession(), "%s tryed to hook the flag in eye of the storm before battleground (ID %u) started.", plr->GetName(), this->m_id);
		SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, plr->GetGUID(), "%s will be removed from the game for cheating.", plr->GetName());
		// Remove player from battleground.
		this->RemovePlayer(plr, false);
		// Kick	player from server.
		plr->Kick(6000);
		return;
	}
#endif
	uint32 spellid=0;
	uint32 x = (uint32)tid;
	if(EOTSm_buffs[x] && EOTSm_buffs[x]->IsInWorld())
	{
		spellid = EOTSm_buffs[x]->GetInfo()->sound3;
		SpellEntry * sp = dbcSpell.LookupEntryForced(spellid);
		if(sp)
		{
			Spell * pSpell = SpellPool.PooledNew();
			pSpell->Init(plr, sp, true, NULL);
			SpellCastTargets targets(plr->GetGUID());
			pSpell->prepare(&targets);
		}
		EOTSm_buffs[x]->Despawn(EOTS_BUFF_RESPAWN_TIME);
	}

	uint32 team = plr->GetTeam();
	if( plr->GetLowGUID() != m_flagHolder )
		return;

	int32 val;
	uint32 i;
	uint32 towers = 0;
	if( team == 0 )
		val = 100;
	else
		val = 0;

	if( m_CPStatus[tid] != val )
		return;			// not captured by our team

	for(i = 0; i < EOTS_TOWER_COUNT; ++i)
	{
		if(m_CPStatus[i] == val)
			towers++;
	}

	/*
	Points from flag captures

	* 1 towers controlled = 75 points
	* 2 towers controlled = 85 points
	* 3 towers controlled = 100 points
	* 4 towers controlled = 500 points 
	*/

	// 25 is guessed
	const static uint32 points[5] = { 25, 75, 85, 100, 500 };
	const char * msgs[2] = { "The Alliance have captured the flag.", "The Horde have captured the flag." };

	SendChatMessage( CHAT_MSG_BG_EVENT_ALLIANCE + team, 0, msgs[team] );
	GivePoints( team, points[towers] );

	m_standFlag->PushToWorld( m_mapMgr );
	m_flagHolder = 0;
	SetWorldState( 2757, 1 );

	plr->RemoveAura( EOTS_NETHERWING_FLAG_SPELL );
	plr->m_bgScore.Misc1++;
	UpdatePvPData();
}
Beispiel #11
0
bool EyeOfTheStorm::GivePoints(uint32 team, uint32 points)
{
	uint32 honor;
	//printf("EOTS: Give team %u %u points.\n", team, points);

	m_points[team] += points;
	if( m_points[team] >= 2000 )
	{
		m_points[team] = 2000;

		m_ended = true;
		m_winningteam = team;
		m_nextPvPUpdateTime = 0;

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

		/* 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)==NULL )// never happen?
					continue;

				/* Winning team will gain 2000 / 12 = 166.6 extra honor points */
				/* On weekend 2000 / 8 = 250 (guessing) */
				/* Losing team will also gain the honor from already earned points */
				honor = m_points[i] / extraHonorDiv;
				(*itr)->m_bgScore.BonusHonor += honor;
				HonorHandler::AddHonorPointsToPlayer((*itr), honor);

				if(i == m_winningteam)
				{				
					Item *item;
					item = objmgr.CreateItem( 29024 , *itr);
					item->SetUInt32Value(ITEM_FIELD_STACK_COUNT,3);
					item->SoulBind();
					if(!(*itr)->GetItemInterface()->AddItemToFreeSlot(item))
					{
						(*itr)->GetSession()->SendNotification("No free slots were found in your inventory!");
						item->DeleteMe();
					}
					else
					{
						SlotResult *lr = (*itr)->GetItemInterface()->LastSearchResult();
						(*itr)->GetSession()->SendItemPushResult(item,false,true,false,true,lr->ContainerSlot,lr->Slot,3);
					}
				}
				else
				{
					Item *item;
					item = objmgr.CreateItem( 29024 , *itr);
					item->SetUInt32Value(ITEM_FIELD_STACK_COUNT,1);
					item->SoulBind();
					if(!(*itr)->GetItemInterface()->AddItemToFreeSlot(item))
					{
						(*itr)->GetSession()->SendNotification("No free slots were found in your inventory!");
						item->DeleteMe();
					}
					else
					{
						SlotResult *lr = (*itr)->GetItemInterface()->LastSearchResult();
						(*itr)->GetSession()->SendItemPushResult(item,false,true,false,true,lr->ContainerSlot,lr->Slot,1);
					}
				}
			}
		}
		m_mainLock.Release();
		SetWorldState( EOTS_WORLDSTATE_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
		UpdatePvPData();
		return true;
	}

	SetWorldState( EOTS_WORLDSTATE_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
	return false;
}
void StrandOfTheAncient::HookOnPlayerDeath(Player * plr)
{
	plr->m_bgScore.Deaths++;
	UpdatePvPData();
}
void StrandOfTheAncient::HookOnHK(Player * plr)
{
	plr->m_bgScore.HonorableKills++;
	UpdatePvPData();
}
void StrandOfTheAncient::HookOnPlayerKill(Player * plr, Player * pVictim)
{
	plr->m_bgScore.KillingBlows++;
	UpdatePvPData();
}
void WarsongGulch::HookOnHK(Player* plr)
{
    plr->m_bgScore.HonorableKills++;
    UpdatePvPData();
}
Beispiel #16
0
void EyeOfTheStorm::HookOnAreaTrigger(Player * plr, uint32 id)
{
	int32 tid = -1;
	int32 bonusid = -1;
	switch(id)
	{
	case 4476:			// BE Tower
		tid = EOTS_TOWER_BE;
		break;
	case 4568:			// BE Tower bonus
		bonusid = EOTS_TOWER_BE;
		break;
	case 4514:			// Fel Reaver Tower
		tid = EOTS_TOWER_FELREAVER;
		break;
	case 4569:			// Fel Reaver Tower bonus
		bonusid = EOTS_TOWER_FELREAVER;
		break;
	case 4518:			// Draenei Tower
		tid = EOTS_TOWER_DRAENEI;
		break;
	case 4571:			// Draenei Tower bonus
		bonusid = EOTS_TOWER_DRAENEI;
		break;
	case 4516:			// Mage Tower
		tid = EOTS_TOWER_MAGE;
		break;
	case 4570:			// Mage Tower bonus
		bonusid = EOTS_TOWER_MAGE;
		break;
	default:
		Log.Error("EyeOfTheStorm", "Encountered unhandled areatrigger id %u", id);
		return;
		break;
	}

	if(plr->IsDead())		// on ne buff pas les joueurs morts ;)
		return;

	if(bonusid > -1){
		uint32 spellid=0;
		uint32 x = (uint32)bonusid;
		if(EOTSm_buffs[x] && EOTSm_buffs[x]->IsInWorld())
		{
			spellid = EOTSm_buffs[x]->GetInfo()->sound3;
			SpellEntry * sp = dbcSpell.LookupEntryForced(spellid);
			if(sp)
			{
				Spell * pSpell = new Spell(plr, sp, true, NULL);
				if (!pSpell)
					return;
				SpellCastTargets targets(plr->GetGUID());
				pSpell->prepare(&targets);
			}
			EOTSm_buffs[x]->Despawn(0, EOTS_BUFF_RESPAWN_TIME);
		}
	}

	if( tid < 0 )
		return;

#ifdef ANTI_CHEAT
	if(!m_started)
	{
		Anticheat_Log->writefromsession(plr->GetSession(), "%s tried to hook the flag in eye of the storm before battleground (ID %u) started.", plr->GetName(), this->m_id);
		SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, plr->GetGUID(), "%s will be removed from the game for cheating.", plr->GetName());
		// Remove player from battleground.
		this->RemovePlayer(plr, false);
		// Kick	player from server.
		plr->Kick(6000);
		return;
	}
#endif

	uint32 team = plr->GetTeam();
	if( plr->GetLowGUID() != m_flagHolder )
		return;

	int32 val;
	uint32 i;
	uint32 towers = 0;
	if( team == 0 )
		val = EOTS_BANNER_ALLIANCE;
	else
		val = EOTS_BANNER_HORDE;

	if(!m_CPBanner[tid] || m_CPBanner[tid]->GetEntry() != static_cast<uint32>( val ) )
		return;			// not captured by our team

	for(i = 0; i < EOTS_TOWER_COUNT; ++i)
	{
		if(m_CPBanner[i] && m_CPBanner[i]->GetEntry() == static_cast<uint32>( val ))
			towers++;
	}

	/*
	Points from flag captures

	* 1 towers controlled = 75 points
	* 2 towers controlled = 85 points
	* 3 towers controlled = 100 points
	* 4 towers controlled = 500 points 
	*/

	// 25 is guessed
	const static uint32 points[5] = { 25, 75, 85, 100, 500 };
	const char * msgs[2] = { "The Alliance have captured the flag.", "The Horde have captured the flag." };

	SendChatMessage( CHAT_MSG_BG_EVENT_ALLIANCE + team, 0, msgs[team] );
	GivePoints( team, points[towers] );

	DropFlag2( plr, id );
	SetWorldState( 2757, 1 );

	plr->RemoveAura( EOTS_NETHERWING_FLAG_SPELL );
	plr->m_bgScore.MiscData[BG_SCORE_EOTS_FLAGS_CAPTURED]++;
	UpdatePvPData();
}
Beispiel #17
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);
	SendChatMessage( CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "|cffffff00This arena will close in 2 minutes.");

	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);
		}
	}
}
Beispiel #18
0
bool EyeOfTheStorm::GivePoints(uint32 team, uint32 points)
{
	//printf("EOTS: Give team %u %u points.\n", team, points);

	m_points[team] += points;
	if((m_points[team] - m_lastHonorGainPoints[team]) >= resourcesToGainBH)
	{
		uint32 honorToAdd = m_honorPerKill;
		m_mainLock.Acquire();
		for(set<Player*>::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
		{
			(*itr)->m_bgScore.BonusHonor += honorToAdd;
			HonorHandler::AddHonorPointsToPlayer((*itr), honorToAdd);
		}

		UpdatePvPData();
		m_mainLock.Release();
		m_lastHonorGainPoints[team] += resourcesToGainBH;
	}

	if( m_points[team] >= 2000 )
	{
		m_points[team] = 2000;

		m_ended = true;
		m_winningteam = static_cast<uint8>( team );
		m_nextPvPUpdateTime = 0;

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

		/* add the marks of honor to all players */
		uint32 lostHonorToAdd = m_honorPerKill;
		uint32 winHonorToAdd = 2 * lostHonorToAdd;
		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)== NULL )
					continue;

				if(i == m_winningteam)
				{
					(*itr)->m_bgScore.BonusHonor += winHonorToAdd;
					HonorHandler::AddHonorPointsToPlayer((*itr), winHonorToAdd);
					Item *item = objmgr.CreateItem( 29024 , *itr );
					if( item != NULL )
					{
						item->SetUInt32Value( ITEM_FIELD_STACK_COUNT, 3 );
						item->SoulBind();
						if( !(*itr)->GetItemInterface()->AddItemToFreeSlot( item ) )
						{
							(*itr)->GetSession()->SendNotification("No free slots were found in your inventory!");
							item->DeleteMe();
						}
						else
						{
							(*itr)->m_bgScore.BonusHonor += lostHonorToAdd;
							HonorHandler::AddHonorPointsToPlayer( (*itr), lostHonorToAdd );
							SlotResult *lr = (*itr)->GetItemInterface()->LastSearchResult();
							(*itr)->GetSession()->SendItemPushResult( item, false, true, false, true, lr->ContainerSlot, lr->Slot, 3 );
						}
					}
					if(i && (*itr)->GetQuestLogForEntry(11341))
						(*itr)->GetQuestLogForEntry(11341)->SendQuestComplete();
					else if((*itr)->GetQuestLogForEntry(11337))
						(*itr)->GetQuestLogForEntry(11337)->SendQuestComplete();
				}
				else
				{
					Item *item = objmgr.CreateItem( 29024 , *itr );
					if( item != NULL )
					{
						item->SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 );
						item->SoulBind();
						if( !(*itr)->GetItemInterface()->AddItemToFreeSlot( item ) )
						{
							(*itr)->GetSession()->SendNotification("No free slots were found in your inventory!");
							item->DeleteMe();
						}
						else
						{
							SlotResult *lr = (*itr)->GetItemInterface()->LastSearchResult();
							(*itr)->GetSession()->SendItemPushResult( item, false, true, false, true, lr->ContainerSlot, lr->Slot, 1 );
						}
					}
				}
			}
		}
		m_mainLock.Release();
		SetWorldState( EOTS_WORLDSTATE_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
		UpdatePvPData();
		return true;
	}

	SetWorldState( EOTS_WORLDSTATE_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
	return false;
}
Beispiel #19
0
void ArathiBasin::HookOnPlayerKill(Player* plr, Player* pVictim)
{
    plr->m_bgScore.KillingBlows++;
    UpdatePvPData();
}
Beispiel #20
0
void EyeOfTheStorm::HookOnPlayerKill(Player * plr, Player * pVictim)
{
	plr->m_bgScore.KillingBlows++;
	UpdatePvPData();
}
Beispiel #21
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();
}
Beispiel #22
0
void EyeOfTheStorm::HookOnHK(Player * plr)
{
	plr->m_bgScore.HonorableKills++;
	UpdatePvPData();
}
Beispiel #23
0
void IsleOfConquest::HookOnPlayerDeath(Player* plr)
{
    plr->m_bgScore.Deaths++;
    UpdatePvPData();
    RemoveReinforcements(plr->GetTeam(), IOC_POINTS_ON_KILL);
}
void WarsongGulch::HookOnAreaTrigger(Player* plr, uint32 id)
{
    int32 buffslot = -1;
    switch(id)
    {
    case 3686:	  // Speed
        buffslot = 0;
        break;
    case 3687:	  // Speed (Horde)
        buffslot = 1;
        break;
    case 3706:	  // Restoration
        buffslot = 2;
        break;
    case 3708:	  // Restoration (Horde)
        buffslot = 3;
        break;
    case 3707:	  // Berserking
        buffslot = 4;
        break;
    case 3709:	  // Berserking (Horde)
        buffslot = 5;
        break;
    }

    if(buffslot >= 0)
    {
        if(m_buffs[buffslot] != 0 && m_buffs[buffslot]->IsInWorld())
        {
            /* apply the buff */
            SpellEntry* sp = dbcSpell.LookupEntry(m_buffs[buffslot]->GetInfo()->sound3);
            Spell* s = sSpellFactoryMgr.NewSpell(plr, sp, true, 0);
            SpellCastTargets targets(plr->GetGUID());
            s->prepare(&targets);

            /* despawn the gameobject (not delete!) */
            m_buffs[buffslot]->Despawn(0, BUFF_RESPAWN_TIME);
        }
        return;
    }

    if(((id == 3646 && plr->IsTeamAlliance()) || (id == 3647 && plr->IsTeamHorde())) && (plr->m_bgHasFlag && m_flagHolders[plr->GetTeam()] == plr->GetLowGUID()))
    {
        if(m_flagHolders[plr->IsTeamHorde() ? TEAM_ALLIANCE : TEAM_HORDE] != 0 || m_dropFlags[plr->IsTeamHorde() ? TEAM_ALLIANCE : TEAM_HORDE]->IsInWorld())
        {
            /* can't cap while flag dropped */
            return;
        }
        float distance = plr->IsTeamAlliance() ? plr->CalcDistance(1540.29f, 1481.34f, 352.64f) : plr->CalcDistance(915.367f, 1433.78f, 346.089f);
        if(distance > 50.0f)
        {
            //50 yards from the spawn, gtfo hacker.
            sCheatLog.writefromsession(plr->GetSession(), "Tried to capture the flag in WSG while being more then 50 yards away. (%f yards)", plr->CalcDistance(915.367f, 1433.78f, 346.089f));
            plr->GetSession()->Disconnect();
            return;
        }

        /* remove the bool from the player so the flag doesn't drop */
        m_flagHolders[plr->GetTeam()] = 0;
        plr->m_bgHasFlag = 0;

        /* remove flag aura from player */
        plr->RemoveAura(23333 + (plr->GetTeam() * 2));

        /* capture flag points */
        plr->m_bgScore.MiscData[BG_SCORE_WSG_FLAGS_CAPTURED]++;

        PlaySoundToAll(plr->IsTeamHorde() ? SOUND_HORDE_SCORES : SOUND_ALLIANCE_SCORES);

        if(plr->IsTeamHorde())
            SendChatMessage(CHAT_MSG_BG_EVENT_HORDE, plr->GetGUID(), "%s captured the Alliance flag!", plr->GetName());
        else
            SendChatMessage(CHAT_MSG_BG_EVENT_ALLIANCE, plr->GetGUID(), "%s captured the Horde flag!", plr->GetName());

        SetWorldState(plr->IsTeamHorde() ? WORLDSTATE_WSG_ALLIANCE_FLAG_DISPLAY : WORLDSTATE_WSG_HORDE_FLAG_DISPLAY, 1);

        // Remove the Other Flag
        if(m_homeFlags[plr->IsTeamHorde() ? TEAM_ALLIANCE : TEAM_HORDE]->IsInWorld())
            m_homeFlags[plr->IsTeamHorde() ? TEAM_ALLIANCE : TEAM_HORDE]->RemoveFromWorld(false);

        // Add the Event to respawn the Flags
        sEventMgr.AddEvent(this, &WarsongGulch::EventReturnFlags, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG, 20000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

        /* give each player on that team bonus honor and reputation*/
        uint32 honorToAdd = 2 * m_honorPerKill;
        uint32 repToAdd = m_isWeekend ? 45 : 35;
        uint32 fact = plr->IsTeamHorde() ? 889 : 890; /*Warsong Outriders : Sliverwing Sentinels*/
        for(set<Player*>::iterator itr = m_players[plr->GetTeam()].begin(); itr != m_players[plr->GetTeam()].end(); ++itr)
        {
            (*itr)->m_bgScore.BonusHonor += honorToAdd;
            HonorHandler::AddHonorPointsToPlayer((*itr), honorToAdd);
            plr->ModStanding(fact, repToAdd);
        }

        m_scores[plr->GetTeam()]++;
        if(m_scores[plr->GetTeam()] == 3)
        {
            /* victory! */
            m_ended = true;
            m_winningteam = (uint8)plr->GetTeam();
            m_nextPvPUpdateTime = 0;

            sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE);
            sEventMgr.AddEvent(TO< CBattleground* >(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

            AddHonorToTeam( m_winningteam, 3 * 185 );

            CastSpellOnTeam( m_winningteam, 69158 );
            CastSpellOnTeam( m_winningteam, 69496 );
            CastSpellOnTeam( m_winningteam, 69497 );
            CastSpellOnTeam( m_winningteam, 69498 );

            if( m_winningteam == TEAM_ALLIANCE )
                AddHonorToTeam( TEAM_HORDE, 1 * 185 );
            else
                AddHonorToTeam( TEAM_ALLIANCE, 1 * 185 );

            m_mainLock.Release();
        }

        /* increment the score world state */
        SetWorldState(plr->IsTeamHorde() ? WORLDSTATE_WSG_HORDE_SCORE : WORLDSTATE_WSG_ALLIANCE_SCORE, m_scores[plr->GetTeam()]);

        UpdatePvPData();
    }
}
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 (int x=0; x<hashmap_length(m_players2[i]); x++) {
				uint32 key;
				if (MAP_OK == hashmap_get_index(m_players2[i], x, (int*)&key, (any_t*) NULL)) {
					PlayerInfo * info = objmgr.GetPlayerInfo(key);
					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(shared_from_this(), EVENT_BATTLEGROUND_CLOSE);
	sEventMgr.RemoveEvents(shared_from_this(), EVENT_ARENA_SHADOW_SIGHT);
	sEventMgr.AddEvent(TO_CBATTLEGROUND(shared_from_this()), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);

	for(int i = 0; i < 2; i++)
	{
		bool victorious = (i != m_losingteam);
		set<PlayerPointer  >::iterator itr = m_players[i].begin();
		for(; itr != m_players[i].end(); itr++)
		{
			PlayerPointer plr = (PlayerPointer )(*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 WarsongGulch::HookFlagDrop(Player* plr, GameObject* obj)
{
    /* picking up a dropped flag */
    if(m_dropFlags[plr->GetTeam()] != obj)
    {
        /* are we returning it? */
        if((obj->GetEntry() == 179785 && plr->IsTeamAlliance()) ||
                (obj->GetEntry() == 179786 && plr->IsTeamHorde()))
        {
            uint32 x = plr->GetTeam() ? 0 : 1;
            sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG + (plr->IsTeamHorde() ? TEAM_ALLIANCE : TEAM_HORDE));

            if(m_dropFlags[x]->IsInWorld())
                m_dropFlags[x]->RemoveFromWorld(false);

            if(m_homeFlags[x]->IsInWorld() == false)
                m_homeFlags[x]->PushToWorld(m_mapMgr);

            plr->m_bgScore.MiscData[BG_SCORE_WSG_FLAGS_RETURNED]++;
            UpdatePvPData();

            if(plr->IsTeamHorde())
                SendChatMessage(CHAT_MSG_BG_EVENT_HORDE, plr->GetGUID(), "The Horde flag was returned to its base by %s!", plr->GetName());
            else
                SendChatMessage(CHAT_MSG_BG_EVENT_ALLIANCE, plr->GetGUID(), "The Alliance flag was returned to its base by %s!", plr->GetName());

            SetWorldState(plr->IsTeamHorde() ? WORLDSTATE_WSG_ALLIANCE_FLAG_DISPLAY : WORLDSTATE_WSG_HORDE_FLAG_DISPLAY, 1);
            PlaySoundToAll(plr->IsTeamHorde() ? SOUND_HORDE_RETURNED : SOUND_ALLIANCE_RETURNED);
        }
        return;
    }

    map<uint32, uint32>::iterator itr = plr->m_forcedReactions.find(1059);
    if(itr != plr->m_forcedReactions.end())
    {
        return;
    }

    if(plr->IsTeamAlliance())
        sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG);
    else
        sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG + 1);

    if(m_dropFlags[plr->GetTeam()]->IsInWorld())
        m_dropFlags[plr->GetTeam()]->RemoveFromWorld(false);

    m_flagHolders[plr->GetTeam()] = plr->GetLowGUID();
    plr->m_bgHasFlag = true;

    /* This is *really* strange. Even though the A9 create sent to the client is exactly the same as the first one, if
     * you spawn and despawn it, then spawn it again it will not show. So we'll assign it a new guid, hopefully that
     * will work.
     * - Burlex
     */
    m_dropFlags[plr->GetTeam()]->SetNewGuid(m_mapMgr->GenerateGameobjectGuid());

    SpellEntry* pSp = dbcSpell.LookupEntry(23333 + (plr->GetTeam() * 2));
    Spell* sp = sSpellFactoryMgr.NewSpell(plr, pSp, true, 0);
    SpellCastTargets targets(plr->GetGUID());
    sp->prepare(&targets);
    SetWorldState(plr->IsTeamHorde() ? WORLDSTATE_WSG_ALLIANCE_FLAG_DISPLAY : WORLDSTATE_WSG_HORDE_FLAG_DISPLAY, 2);
    if(plr->IsTeamHorde())
        SendChatMessage(CHAT_MSG_BG_EVENT_HORDE, plr->GetGUID(), "The Alliance's flag has been taken by %s !", plr->GetName());
    else
        SendChatMessage(CHAT_MSG_BG_EVENT_ALLIANCE, plr->GetGUID(), "The Horde's flag has been taken by %s !", plr->GetName());
}
void ArathiBasin::HookOnHK(Player * plr)
{
	plr->m_bgScore.HonorableKills++;
	UpdatePvPData();
}
void WarsongGulch::HookOnPlayerKill(Player* plr, Player* pVictim)
{
    plr->m_bgScore.KillingBlows++;
    UpdatePvPData();
}
Beispiel #29
0
void ArathiBasin::HookOnPlayerDeath(Player * plr)
{
	// nothing in this BG
	plr->m_bgScore.Deaths++;
	UpdatePvPData();
}
Beispiel #30
0
void IsleOfConquest::AssaultControlPoint(Player* pPlayer, uint32 Id)
{
	if(!m_started)
	{
		SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, pPlayer->GetGUID(), "%s has been removed from the game for cheating.", pPlayer->GetName());
		pPlayer->SoftDisconnect();
		return;
	}

	bool isVirgin = false;

	uint32 Team = pPlayer->m_bgTeam;
	uint32 Owner;

	if(m_basesOwnedBy[Id]==-1 && m_basesAssaultedBy[Id]==-1)
	{
		isVirgin = true;
		// omgwtfbbq our flag is a virgin?
		SetWorldState(NeutralFields[Id], 0);
	}

	if(m_basesOwnedBy[Id] != -1)
	{
		Owner = m_basesOwnedBy[Id];

		// set it to uncontrolled for now
		m_basesOwnedBy[Id] = -1;

		// this control point just got taken over by someone! oh noes!
		if( m_spiritGuides[Id] != NULL )
		{
			map<Creature*,set<uint32> >::iterator itr = m_resurrectMap.find(m_spiritGuides[Id]);
			if( itr != m_resurrectMap.end() )
			{
				for( set<uint32>::iterator it2 = itr->second.begin(); it2 != itr->second.end(); it2++ )
				{
					Player* r_plr = m_mapMgr->GetPlayer( *it2 );
					if( r_plr != NULL && r_plr->IsDead())
					{
						HookHandleRepop( r_plr );
						QueueAtNearestSpiritGuide(r_plr, itr->first);
					}
				}
			}
			m_resurrectMap.erase( itr );
			if(m_spiritGuides[Id] && m_spiritGuides[Id]->IsInWorld())
			{
				m_spiritGuides[Id]->Despawn( 0, 0 );
				m_spiritGuides[Id] = NULL;
			}
		}

		// reset the world states
		SetWorldState(OwnedFields[Id][Owner], 0);

		// modify the resource update time period
		if(m_capturedBases[Owner]==0)
			event_RemoveEvents(EVENT_IOC_RESOURCES_UPDATE_TEAM_0+Owner);
		else
			event_ModifyTime(EVENT_IOC_RESOURCES_UPDATE_TEAM_0 + Owner, ResourceUpdateIntervals[m_capturedBases[Owner]]);
	}
	pPlayer->AddHonor(25);
	// Contested Flag, not ours, and is not virgin
	if( !isVirgin && m_basesLastOwnedBy[Id] == int32(Team) && m_basesOwnedBy[Id] == -1 )
	{
		SetWorldState(AssaultFields[Id][Team ? 0 : 1], 0);
		event_RemoveEvents(EVENT_IOC_CAPTURE_CP_1 + Id);
		SendChatMessage(Team ?  CHAT_MSG_BG_EVENT_HORDE :  CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N has defended the %s!", ControlPointNames[Id]);
		m_basesAssaultedBy[Id] = Team;
		CaptureControlPoint( Id, Team );
		pPlayer->m_bgScore.MiscData[BG_SCORE_IOC_BASE_DEFENDED]++;
		return;
	}

	// n***a stole my flag!
	if(m_basesAssaultedBy[Id] != -1)
	{
		Owner = m_basesAssaultedBy[Id];
		m_basesAssaultedBy[Id] = Team;
		SetWorldState(AssaultFields[Id][Owner], 0);
		sEventMgr.RemoveEvents(this, EVENT_IOC_CAPTURE_CP_1 + Id);
	}

	m_basesAssaultedBy[Id] = Team;

	// spawn the new control point gameobject
	SpawnControlPoint(Id, Team ? IOC_SPAWN_TYPE_HORDE_ASSAULT : IOC_SPAWN_TYPE_ALLIANCE_ASSAULT);

	// send out the chat message and sound
	SendChatMessage(Team ?  CHAT_MSG_BG_EVENT_HORDE :  CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N claims the %s! If left unchallenged, the %s will control it in 1 minute!", ControlPointNames[Id],
		Team ? "Horde" : "Alliance");
	// guessed
	PlaySoundToAll(Team ? SOUND_ALLIANCE_CAPTURE : SOUND_HORDE_CAPTURE);

	// update the client's map with the new assaulting field
	SetWorldState(AssaultFields[Id][Team], 1);

	// create the 60 second event.
	sEventMgr.AddEvent(this, &IsleOfConquest::CaptureControlPoint, Id, Team, EVENT_IOC_CAPTURE_CP_1 + Id, 60000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

	// update players info
	pPlayer->m_bgScore.MiscData[BG_SCORE_IOC_BASE_ASSAULTED]++;
	UpdatePvPData();
	if(Id == 5)
	{
		if(m_salesman != NULL)
			m_salesman->Despawn(0,0);
	}
}