コード例 #1
0
void ArathiBasin::CaptureControlPoint(uint32 Id, uint32 Team)
{
	if(m_basesOwnedBy[Id] != -1)
	{
		// there is a very slim chance of this happening, 2 teams evnets could clash..
		// just in case...
		return;
	}

	// anticheat, not really necessary because this is a server method but anyway
	if(m_basesAssaultedBy[Id] != (int32)Team)
		return;

	
	m_basesLastOwnedBy[Id] = Team;

	m_flagIsVirgin[Id] = false;

	m_basesOwnedBy[Id] = Team;
	m_basesAssaultedBy[Id]=-1;

	// remove the other spirit guide (if it exists) // burlex: shouldnt' happen
	if(m_spiritGuides[Id] != NULL)
	{
		RemoveSpiritGuide(m_spiritGuides[Id]);
		m_spiritGuides[Id]->Despawn(0,0);
	}

	// spawn the spirit guide for our faction
	m_spiritGuides[Id] = SpawnSpiritGuide(GraveyardLocations[Id][0], GraveyardLocations[Id][1], GraveyardLocations[Id][2], 0.0f, Team);
	AddSpiritGuide(m_spiritGuides[Id]);

	// send the chat message/sounds out
	PlaySoundToAll(Team ? SOUND_HORDE_SCORES : SOUND_ALLIANCE_SCORES);
	SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, 0, "The %s has taken the %s!", Team ? "Horde" : "Alliance", ControlPointNames[Id]);
	
	// update the overhead display on the clients (world states)
	m_capturedBases[Team]++;
	m_mapMgr->GetStateManager().UpdateWorldState(Team ? WORLDSTATE_AB_HORDE_CAPTUREBASE : WORLDSTATE_AB_ALLIANCE_CAPTUREBASE, m_capturedBases[Team]);

	// respawn the control point with the correct aura
	SpawnControlPoint(Id, Team ? AB_SPAWN_TYPE_HORDE_CONTROLLED : AB_SPAWN_TYPE_ALLIANCE_CONTROLLED);

	// update the map
	m_mapMgr->GetStateManager().UpdateWorldState(AssaultFields[Id][Team], 0);
	m_mapMgr->GetStateManager().UpdateWorldState(OwnedFields[Id][Team], 1);

	// resource update event. :)
	if(m_capturedBases[Team]==1)
	{
		// first
		sEventMgr.AddEvent(TO_ARATHIBASIN(shared_from_this()),&ArathiBasin::EventUpdateResources, (uint32)Team, EVENT_AB_RESOURCES_UPDATE_TEAM_0+Team, ResourceUpdateIntervals[1], 0,
			EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
	}
	else
	{
		// not first
		event_ModifyTime(EVENT_AB_RESOURCES_UPDATE_TEAM_0+Team, ResourceUpdateIntervals[m_capturedBases[Team]]);
	}
}
コード例 #2
0
void IsleOfConquest::CaptureControlPoint(uint32 Id, uint32 Team)
{
	if(m_basesOwnedBy[Id] != -1)
	{
		// there is a very slim chance of this happening, 2 teams evnets could clash..
		// just in case...
		return;
	}

	// anticheat, not really necessary because this is a server method but anyway
	if(m_basesAssaultedBy[Id] != (int32)Team)
		return;


	m_basesLastOwnedBy[Id] = Team;

	m_flagIsVirgin[Id] = false;

	m_basesOwnedBy[Id] = Team;
	m_basesAssaultedBy[Id]=-1;

	// remove the other spirit guide (if it exists) // burlex: shouldnt' happen
	if(m_spiritGuides[Id] != NULL)
	{
		RemoveSpiritGuide(m_spiritGuides[Id]);
		m_spiritGuides[Id]->Despawn(0,0);
	}

	// spawn the spirit guide for our faction
	m_spiritGuides[Id] = SpawnSpiritGuide(GraveyardLocations[Id][0], GraveyardLocations[Id][1], GraveyardLocations[Id][2], 0.0f, Team);
	AddSpiritGuide(m_spiritGuides[Id]);

	// send the chat message/sounds out
	PlaySoundToAll(Team ? SOUND_HORDE_SCORES : SOUND_ALLIANCE_SCORES);
	SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, 0, "The %s has taken the %s!", Team ? "Horde" : "Alliance", ControlPointNames[Id]);

	// update the overhead display on the clients (world states)
	m_capturedBases[Team]++;
	// respawn the control point with the correct aura
	SpawnControlPoint(Id, Team ? IOC_SPAWN_TYPE_HORDE_CONTROLLED : IOC_SPAWN_TYPE_ALLIANCE_CONTROLLED);

	// update the map
	SetWorldState(AssaultFields[Id][Team], 0);
	SetWorldState(OwnedFields[Id][Team], 1);
	AddHonorToTeam(5, Team);
	ApplyCaptureBonus(Id, Team);
	if(Id == 5)
		Updateworkshop(Team);
}
コード例 #3
0
ファイル: IsleOfConquest.cpp プロジェクト: Declipe/AscEmu
void IsleOfConquest::SpawnGraveyard( uint32 id, uint32 team ){
    if( id >= IOC_NUM_GRAVEYARDS )
        return;

    IOCGraveyard &gy = graveyards[ id ];

    if( gy.owner == team )
        return;

    gy.owner = team;
    if( gy.spiritguide != NULL ){
        RemoveSpiritGuide( gy.spiritguide );
        gy.spiritguide->Despawn( 0, 0 );
    }

    gy.spiritguide = SpawnSpiritGuide( SpiritGuideLocations[ id ], team );
    AddSpiritGuide( gy.spiritguide );
}
コード例 #4
0
void ArathiBasin::CaptureControlPoint(uint32 Id, uint32 Team)
{
	if(m_basesOwnedBy[Id] != -1)
	{
		// there is a very slim chance of this happening, 2 teams events could clash..
		// just in case...
		return;
	}

	// anti cheat, not really necessary because this is a server method but anyway
	if(m_basesAssaultedBy[Id] != (int32)Team)
		return;

	m_basesOwnedBy[Id] = Team;
	m_basesAssaultedBy[Id] = -1;
	m_basesLastOwnedBy[Id] = -1;

	// remove the other spirit guide (if it exists) // burlex: shouldn't' happen
	if(m_spiritGuides[Id] != NULL)
	{
		RemoveSpiritGuide(m_spiritGuides[Id]);
		m_spiritGuides[Id]->Despawn(0, 0);
	}

	// spawn the spirit guide for our faction
	m_spiritGuides[Id] = SpawnSpiritGuide(GraveyardLocations[Id][0], GraveyardLocations[Id][1], GraveyardLocations[Id][2], 0.0f, Team);
	AddSpiritGuide(m_spiritGuides[Id]);

	// send the chat message/sounds out
	PlaySoundToAll(Team ? SOUND_HORDE_CAPTURE : SOUND_ALLIANCE_CAPTURE);
	SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, 0, "The %s has taken the %s!", Team ? "Horde" : "Alliance", ControlPointNames[Id]);
	DefFlag[Id][0] = false;
	DefFlag[Id][1] = false;

	// update the overhead display on the clients (world states)
	m_capturedBases[Team]++;
	SetWorldState(Team ? WORLDSTATE_AB_HORDE_CAPTUREBASE : WORLDSTATE_AB_ALLIANCE_CAPTUREBASE, m_capturedBases[Team]);

	if(m_capturedBases[Team] >= 4)
	{
		m_mainLock.Acquire();
		for(set<Player*>::iterator itr = m_players[Team].begin(); itr != m_players[Team].end(); ++itr)
		{
			if(Team)
			{
				if(m_capturedBases[Team] >= 4 && (*itr)->GetQuestLogForEntry(8121))
					(*itr)->GetQuestLogForEntry(8121)->SendQuestComplete();
				if(m_capturedBases[Team] == 5 && (*itr)->GetQuestLogForEntry(8122))
					(*itr)->GetQuestLogForEntry(8122)->SendQuestComplete();
			}
			else
			{
				if(m_capturedBases[Team] >= 4 && (*itr)->GetQuestLogForEntry(8114))
					(*itr)->GetQuestLogForEntry(8114)->SendQuestComplete();
				if(m_capturedBases[Team] == 5 && (*itr)->GetQuestLogForEntry(8115))
					(*itr)->GetQuestLogForEntry(8115)->SendQuestComplete();
			}
		}
		m_mainLock.Release();
	}

	// respawn the control point with the correct aura
	SpawnControlPoint(Id, Team ? AB_SPAWN_TYPE_HORDE_CONTROLLED : AB_SPAWN_TYPE_ALLIANCE_CONTROLLED);

	// update the map
	SetWorldState(AssaultFields[Id][Team], 0);
	SetWorldState(OwnedFields[Id][Team], 1);

	// resource update event. :)
	if(m_capturedBases[Team] == 1)
	{
		// first
		sEventMgr.AddEvent(this, &ArathiBasin::EventUpdateResources, (uint32)Team, EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Team, ResourceUpdateIntervals[1], 0,
		                   EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
	}
	else
	{
		// not first
		event_ModifyTime(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Team, ResourceUpdateIntervals[m_capturedBases[Team]]);
	}
}
コード例 #5
0
ファイル: EyeOfTheStorm.cpp プロジェクト: WowDevs/Sandshroud
void EyeOfTheStorm::UpdateCPs()
{
    uint32 plrcounts[2] = { 0, 0 };

    // details:
    //   loop through inrange players, for new ones, send the enable CP worldstate.
    //   the value of the map is a timestamp of the last update, to avoid cpu time wasted
    //   doing lookups of objects that have already been updated

    unordered_set<Player*  >::iterator itr;
    unordered_set<Player*  >::iterator itrend;
    map<uint32,uint32>::iterator it2, it3;
    uint32 timeptr = (uint32)UNIXTIME;
    bool in_range;
    bool is_valid;
    Player* plr;
    uint32 i;

    for(i = 0; i < EOTS_TOWER_COUNT; i++)
    {
        itr = m_CPStatusGO[i]->GetInRangePlayerSetBegin();
        itrend = m_CPStatusGO[i]->GetInRangePlayerSetEnd();
        plrcounts[0] = plrcounts[1] = 0;

        for(; itr != itrend; itr++)
        {
            if( !(*itr)->IsPvPFlagged() || (*itr)->InStealth() || (*itr)->m_invisible || (*itr)->SchoolImmunityList[0] || (*itr)->m_bgFlagIneligible )
                is_valid = false;
            else
                is_valid = true;

            in_range = ((*itr)->isAlive() && m_CPStatusGO[i]->GetDistanceSq((*itr)) <= EOTS_CAPTURE_DISTANCE) ? true : false;

            it2 = m_CPStored[i].find((*itr)->GetLowGUID());
            if( it2 == m_CPStored[i].end() )
            {
                // new player :)
                if( in_range )
                {
                    (*itr)->SendWorldStateUpdate(WORLDSTATE_EOTS_PVP_CAPTURE_BAR_DISPLAY, 1);
                    (*itr)->SendWorldStateUpdate(WORLDSTATE_EOTS_PVP_CAPTURE_BAR_VALUE, m_CPStatus[i]);
                    m_CPStored[i].insert(make_pair((*itr)->GetLowGUID(), timeptr));

                    if( is_valid )
                        plrcounts[(*itr)->GetTeam()]++;
                }
            }
            else
            {
                // oldie
                if( !in_range )
                {
                    (*itr)->SendWorldStateUpdate(WORLDSTATE_EOTS_PVP_CAPTURE_BAR_DISPLAY, 0);
                    m_CPStored[i].erase(it2);
                }
                else
                {
                    (*itr)->SendWorldStateUpdate(WORLDSTATE_EOTS_PVP_CAPTURE_BAR_VALUE, m_CPStatus[i]);
                    it2->second = timeptr;
                    if( is_valid )
                        plrcounts[(*itr)->GetTeam()]++;
                }
            }
        }

        // handle stuff for the last tick
        // change the flag depending on cp status
        if( m_CPStatus[i] < 50 )
        {
            if( ( m_CPBanner[i] && m_CPBanner[i]->GetEntry() != EOTS_BANNER_HORDE ) ||
              ( m_CPBanner2[i] && m_CPBanner2[i]->GetEntry() != EOTS_BANNER_HORDE ) ||
              ( m_CPBanner3[i] && m_CPBanner3[i]->GetEntry() != EOTS_BANNER_HORDE ) )
            {
                RespawnCPFlag(i, EOTS_BANNER_HORDE);
                if( m_spiritGuides[i] != NULL )
                {
                    RepopPlayersOfTeam( 0, m_spiritGuides[i] );
                    m_spiritGuides[i]->Despawn( 0, 0 );
                    RemoveSpiritGuide( m_spiritGuides[i] );
                    m_spiritGuides[i] = NULLCREATURE;
                }

                m_spiritGuides[i] = SpawnSpiritGuide( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0, 1 );
                AddSpiritGuide( m_spiritGuides[i] );
                SendChatMessage(CHAT_MSG_BG_SYSTEM_HORDE, 0, "The Horde have captured the %s.", EOTSCPNames[i]);

                // set some world states
                m_mapMgr->GetStateManager().UpdateWorldState(EOTSNeturalDisplayFields[i], 0);
                m_mapMgr->GetStateManager().UpdateWorldState(EOTSHordeDisplayFields[i], 1);
                m_mapMgr->GetStateManager().UpdateWorldState(EOTSAllianceDisplayFields[i], 0);
                m_towerCount[1]++;
                m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_HORDE_BASES, m_towerCount[1] );
            }
        }
        else if( m_CPStatus[i] > 50 )
        {
            if( ( m_CPBanner[i] && m_CPBanner[i]->GetEntry() != EOTS_BANNER_ALLIANCE ) ||
              ( m_CPBanner2[i] && m_CPBanner2[i]->GetEntry() != EOTS_BANNER_ALLIANCE ) ||
              ( m_CPBanner3[i] && m_CPBanner3[i]->GetEntry() != EOTS_BANNER_ALLIANCE ) )
            {
                RespawnCPFlag(i, EOTS_BANNER_ALLIANCE);
                if( m_spiritGuides[i] != NULL )
                {
                    RepopPlayersOfTeam( 1, m_spiritGuides[i] );
                    m_spiritGuides[i]->Despawn( 0, 0 );
                    RemoveSpiritGuide( m_spiritGuides[i] );
                    m_spiritGuides[i] = NULLCREATURE;
                }

                m_spiritGuides[i] = SpawnSpiritGuide( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0, 0 );
                AddSpiritGuide( m_spiritGuides[i] );
                SendChatMessage(CHAT_MSG_BG_SYSTEM_ALLIANCE, 0, "The Alliance have captured the %s.", EOTSCPNames[i]);

                // set some world states
                m_mapMgr->GetStateManager().UpdateWorldState(EOTSNeturalDisplayFields[i], 0);
                m_mapMgr->GetStateManager().UpdateWorldState(EOTSHordeDisplayFields[i], 0);
                m_mapMgr->GetStateManager().UpdateWorldState(EOTSAllianceDisplayFields[i], 1);
                m_towerCount[0]++;
                m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_ALLIANCE_BASES, m_towerCount[0] );
            }
        }
        else
        {
            if( ( m_CPBanner[i] && m_CPBanner[i]->GetEntry() != EOTS_BANNER_NEUTRAL ) ||
              ( m_CPBanner2[i] && m_CPBanner2[i]->GetEntry() != EOTS_BANNER_NEUTRAL ) ||
              ( m_CPBanner3[i] && m_CPBanner3[i]->GetEntry() != EOTS_BANNER_NEUTRAL ) )
            {
                // has to be below or equal to 50, or above/equal
                if( ( m_CPBanner[i]->GetEntry() == EOTS_BANNER_ALLIANCE && m_CPStatus[i] <= 50 ) ||
                    ( m_CPBanner[i]->GetEntry() == EOTS_BANNER_HORDE && m_CPStatus[i] >= 50 ) ||
                    ( m_CPBanner2[i]->GetEntry() == EOTS_BANNER_ALLIANCE && m_CPStatus[i] <= 50 ) ||
                    ( m_CPBanner2[i]->GetEntry() == EOTS_BANNER_HORDE && m_CPStatus[i] >= 50 ) ||
                    ( m_CPBanner3[i]->GetEntry() == EOTS_BANNER_ALLIANCE && m_CPStatus[i] <= 50 ) ||
                    ( m_CPBanner3[i]->GetEntry() == EOTS_BANNER_HORDE && m_CPStatus[i] >= 50 ) )
                {
                    if( m_CPBanner[i] && m_CPBanner[i]->GetEntry() == EOTS_BANNER_ALLIANCE )
                    {
                        SendChatMessage(CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "The Alliance have lost control of the %s.", EOTSCPNames[i]);
                        m_towerCount[0]--;
                        if( m_towerCount[0] < 0 )
                            m_towerCount[0] = 0;

                        m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_ALLIANCE_BASES, m_towerCount[0] );
                    }
                    else
                    {
                        SendChatMessage(CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "The Horde have lost control of the %s.", EOTSCPNames[i]);
                        m_towerCount[1]--;
                        if( m_towerCount[1] < 0 )
                            m_towerCount[1] = 0;


                        m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_HORDE_BASES, m_towerCount[1] );
                    }

                    RespawnCPFlag(i, EOTS_BANNER_NEUTRAL);
                    if( m_spiritGuides[i] != NULL )
                    {
                        RepopPlayersOfTeam( -1, m_spiritGuides[i] );
                        m_spiritGuides[i]->Despawn( 0, 0 );
                        RemoveSpiritGuide( m_spiritGuides[i] );
                        m_spiritGuides[i] = NULLCREATURE;
                    }

                    // set some world states
                    m_mapMgr->GetStateManager().UpdateWorldState(EOTSNeturalDisplayFields[i], 1);
                    m_mapMgr->GetStateManager().UpdateWorldState(EOTSHordeDisplayFields[i], 0);
                    m_mapMgr->GetStateManager().UpdateWorldState(EOTSAllianceDisplayFields[i], 0);
                }
            }
        }

        // send any out of range players the disable flag
        for(it2 = m_CPStored[i].begin(); it2 != m_CPStored[i].end(); )
        {
            it3 = it2;
            ++it2;

            if( it3->second != timeptr )
            {
                plr = m_mapMgr->GetPlayer(it3->first);

                // they WILL be out of range at this point. this is guaranteed. means they left the set rly quickly.
                if( plr != NULL )
                    plr->SendWorldStateUpdate(WORLDSTATE_EOTS_PVP_CAPTURE_BAR_DISPLAY, 0);

                m_CPStored[i].erase(it3);
            }
        }

        // work out current status for next tick
        int32 delta;
        if( plrcounts[0] > plrcounts[1] )
        {
            delta = plrcounts[0] - plrcounts[1];

            // cap it at 25 so the banner always gets removed.
            if( delta > 25 )
                delta = 25;

            m_CPStatus[i] += delta;
            if( m_CPStatus[i] < 0 )
                m_CPStatus[i] = 0;
        }
        else if( plrcounts[1] > plrcounts[0] )
        {
            delta = plrcounts[1] - plrcounts[0];

            // cap it at 25 so the banner always gets removed.
            if( delta > 25 )
                delta = 25;


            m_CPStatus[i] -= delta;
            if( m_CPStatus[i] > 100 )
                m_CPStatus[i] = 100;
        }
    }


}
コード例 #6
0
ファイル: EyeOfTheStorm.cpp プロジェクト: lev1976g/NoxicCore
void EyeOfTheStorm::UpdateCPs()
{
	uint32 i;
	set< Object* >::iterator itr, itrend;
	Player* plr;
	GameObject* go;
	int32 delta = 0;
	uint32 playercounts[2];
	uint32 towers[2] = {0, 0};
	EOTSCaptureDisplayList::iterator eitr, eitr2, eitrend;
	EOTSCaptureDisplayList* disp;

	for(i = 0; i < EOTS_TOWER_COUNT; ++i)
	{
		/* loop players in range, add any that aren't in the set to the set */
		playercounts[0] = playercounts[1] = 0;
		go = m_CPStatusGO[i];
		disp = &m_CPDisplay[i];

		itr = go->GetInRangePlayerSetBegin();
		itrend = go->GetInRangePlayerSetEnd();

		for(; itr != itrend; ++itr)
		{
			plr = TO< Player* >(*itr);
			if(plr->isAlive() && !(plr->IsStealth()) && !(plr->m_invisible) && !(plr->SchoolImmunityList[0]) && plr->GetDistance2dSq(go) <= EOTS_CAPTURE_DISTANCE)
			{
				playercounts[plr->GetTeam()]++;

				if(disp->find(plr) == disp->end())
				{
					disp->insert(plr);
					plr->SendWorldStateUpdate(WORLDSTATE_EOTS_DISPLAYON, 1);
				}
			}
		}

		/* score diff calculation */
		//printf("EOTS: Playercounts = %u %u\n", playercounts[0], playercounts[1]);
		if(playercounts[0] != playercounts[1])
		{
			if(playercounts[0] > playercounts[1])
				delta = playercounts[0];
			else if(playercounts[1] > playercounts[0])
				delta = -(int32)playercounts[1];

			delta *= EOTS_CAPTURE_RATE;
			m_CPStatus[i] += delta;
			if(m_CPStatus[i] > 100)
				m_CPStatus[i] = 100;
			else if(m_CPStatus[i] < 0)
				m_CPStatus[i] = 0;

			// change the flag depending on cp status
			if(m_CPStatus[i] <= 30)
			{
				if(m_CPBanner[i] && m_CPBanner[i]->GetEntry() != EOTS_BANNER_HORDE)
				{
					RespawnCPFlag(i, EOTS_BANNER_HORDE);
					if(m_spiritGuides[i] != NULL)
					{
						RepopPlayersOfTeam(0, m_spiritGuides[i]);
						m_spiritGuides[i]->Despawn(0, 0);
						RemoveSpiritGuide(m_spiritGuides[i]);
						m_spiritGuides[i] = NULL;
					}
					m_spiritGuides[i] = SpawnSpiritGuide(EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0, 1);
					AddSpiritGuide(m_spiritGuides[i]);

					SetWorldState(m_iconsStates[i][0], 0);
					SetWorldState(m_iconsStates[i][1], 0);
					SetWorldState(m_iconsStates[i][2], 1);
					SendChatMessage(CHAT_MSG_BG_EVENT_HORDE, 0, "The Horde has taken the %s !", EOTSControlPointNames[i]);
					PlaySoundToAll(SOUND_HORDE_CAPTURE);
				}
			}
			else if(m_CPStatus[i] >= 70)
			{
				if(m_CPBanner[i] && m_CPBanner[i]->GetEntry() != EOTS_BANNER_ALLIANCE)
				{
					RespawnCPFlag(i, EOTS_BANNER_ALLIANCE);
					if(m_spiritGuides[i] != NULL)
					{
						RepopPlayersOfTeam(1, m_spiritGuides[i]);
						m_spiritGuides[i]->Despawn(0, 0);
						RemoveSpiritGuide(m_spiritGuides[i]);
						m_spiritGuides[i] = NULL;
					}

					m_spiritGuides[i] = SpawnSpiritGuide(EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0, 0);
					AddSpiritGuide(m_spiritGuides[i]);

					SetWorldState(m_iconsStates[i][0], 0);
					SetWorldState(m_iconsStates[i][1], 1);
					SetWorldState(m_iconsStates[i][2], 0);
					SendChatMessage(CHAT_MSG_BG_EVENT_ALLIANCE, 0, "The Alliance has taken the %s", EOTSControlPointNames[i]);
					PlaySoundToAll(SOUND_ALLIANCE_CAPTURE);
				}
			}
			else
			{
				if(m_CPBanner[i]->GetEntry() != EOTS_BANNER_NEUTRAL)
				{
					if(m_CPBanner[i]->GetEntry() == EOTS_BANNER_ALLIANCE)
					{
						SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, 0, "The Alliance has lost the control of the %s.", EOTSControlPointNames[i]);
					}
					else if(m_CPBanner[i]->GetEntry() == EOTS_BANNER_HORDE)
					{
						SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, 0, "The Horde has lost the control of the %s.", EOTSControlPointNames[i]);
					}
					RespawnCPFlag(i, EOTS_BANNER_NEUTRAL);
					if(m_spiritGuides[i] != NULL)
					{
						RepopPlayersOfTeam(-1, m_spiritGuides[i]);
						m_spiritGuides[i]->Despawn(0, 0);
						RemoveSpiritGuide(m_spiritGuides[i]);
						m_spiritGuides[i] = NULL;
					}
					SetWorldState(m_iconsStates[i][0], 1);
					SetWorldState(m_iconsStates[i][1], 0);
					SetWorldState(m_iconsStates[i][2], 0);
				}
			}
		}

		/* update the players with the new value */
		eitr = disp->begin();
		eitrend = disp->end();

		for(; eitr != eitrend;)
		{
			plr = *eitr;
			eitr2 = eitr;
			++eitr;

			if(plr->GetDistance2dSq(go) > EOTS_CAPTURE_DISTANCE)
			{
				disp->erase(eitr2);
				plr->SendWorldStateUpdate(WORLDSTATE_EOTS_DISPLAYON, 0);			// hide the cp bar
			}
			else
				plr->SendWorldStateUpdate(WORLDSTATE_EOTS_DISPLAYVALUE, m_CPStatus[i]);
		}
	}

	for(i = 0; i < EOTS_TOWER_COUNT; ++i)
	{
		if(m_CPBanner[i] && m_CPBanner[i]->GetEntry() == EOTS_BANNER_ALLIANCE)
			towers[0]++;
		else if(m_CPBanner[i] && m_CPBanner[i]->GetEntry() == EOTS_BANNER_HORDE)
			towers[1]++;
	}

	SetWorldState(WORLDSTATE_EOTS_ALLIANCE_BASES, towers[0]);
	SetWorldState(WORLDSTATE_EOTS_HORDE_BASES, towers[1]);
}
コード例 #7
0
ファイル: EyeOfTheStorm.cpp プロジェクト: Chero/abcwow
void EyeOfTheStorm::UpdateCPs()
{
	uint32 i;
	set<Player*>::iterator itr, itrend;
	Player * plr;
	GameObject * go;
	int32 delta;
	uint32 playercounts[2];
	uint32 towers[2] = {0,0};
	EOTSCaptureDisplayList::iterator eitr, eitr2, eitrend;
	EOTSCaptureDisplayList * disp;

	for(i = 0; i < EOTS_TOWER_COUNT; ++i)
	{
		/* loop players inrange, add any that arent in the set to the set */
		playercounts[0] = playercounts[1] = 0;
		go = m_CPStatusGO[i];
		disp = &m_CPDisplay[i];
		itr = go->GetInRangePlayerSetBegin();
		itrend = go->GetInRangePlayerSetEnd();

		for( ; itr != itrend; ++itr )
		{
			plr = *itr;
			if( (plr->GetDistance2dSq( go ) <= EOTS_CAPTURE_DISTANCE) && plr->isAlive() && !plr->IsStealth() )
			{
				playercounts[plr->GetTeam()]++;

				if( disp->find( plr ) == disp->end() )
				{
					disp->insert( plr );
					plr->SendWorldStateUpdate(EOTS_WORLDSTATE_DISPLAYON, 1);
				}
			}
		}

		/* score diff calculation */
		//printf("EOTS: Playercounts = %u %u\n", playercounts[0], playercounts[1]);
		if(playercounts[0] != playercounts[1])
		{
			if(playercounts[0] > playercounts[1])
				delta = playercounts[0];
			else if(playercounts[1] > playercounts[0])
				delta = -(int32)playercounts[1];

			delta *= EOTS_CAPTURE_RATE;
			m_CPStatus[i] += delta;
			if( m_CPStatus[i] > 100 )
				m_CPStatus[i] = 100;
			else if( m_CPStatus[i] < 0 )
				m_CPStatus[i] = 0;

			// change the flag depending on cp status
			if( m_CPStatus[i] == 0 )
			{
				if( m_CPBanner[i]->GetEntry() != EOTS_BANNER_HORDE )
				{
					SetWorldState( TowerWorldStates[i][0], 0);
					SetWorldState( TowerWorldStates[i][1], 1);

					RespawnCPFlag(i, EOTS_BANNER_HORDE);
					if( m_spiritGuides[i] != NULL )
					{
						RepopPlayersOfTeam( 0, m_spiritGuides[i] );
						m_spiritGuides[i]->Despawn( 0, 0 );
						RemoveSpiritGuide( m_spiritGuides[i] );
						m_spiritGuides[i] = NULL;
					}

					m_spiritGuides[i] = SpawnSpiritGuide( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0, 1 );
					AddSpiritGuide( m_spiritGuides[i] );
				}
			}
			else if( m_CPStatus[i] == 100 )
			{
				if( m_CPBanner[i]->GetEntry() != EOTS_BANNER_ALLIANCE )
				{
					SetWorldState( TowerWorldStates[i][1], 0);
					SetWorldState( TowerWorldStates[i][0], 1);

					RespawnCPFlag(i, EOTS_BANNER_ALLIANCE);
					if( m_spiritGuides[i] != NULL )
					{
						RepopPlayersOfTeam( 1, m_spiritGuides[i] );
						m_spiritGuides[i]->Despawn( 0, 0 );
						RemoveSpiritGuide( m_spiritGuides[i] );
						m_spiritGuides[i] = NULL;
					}

					m_spiritGuides[i] = SpawnSpiritGuide( EOTSGraveyardLocations[i][0], EOTSGraveyardLocations[i][1], EOTSGraveyardLocations[i][2], 0, 0 );
					AddSpiritGuide( m_spiritGuides[i] );
				}
			}
			else
			{
				if( m_CPBanner[i]->GetEntry() != EOTS_BANNER_NEUTRAL )
				{

					for( uint32 j = 0; j < 2; ++j )
						SetWorldState( TowerWorldStates[i][j], 0);

					RespawnCPFlag(i, EOTS_BANNER_NEUTRAL);
					if( m_spiritGuides[i] != NULL )
					{
						RepopPlayersOfTeam( -1, m_spiritGuides[i] );
						m_spiritGuides[i]->Despawn( 0, 0 );
						RemoveSpiritGuide( m_spiritGuides[i] );
						m_spiritGuides[i] = NULL;
					}
				}
			}
		}

		/* update the players with the new value */
		eitr = disp->begin();
		eitrend = disp->end();

		for( ; eitr != eitrend; )
		{
			plr = *eitr;
			eitr2 = eitr;
			++eitr;

			if( plr->GetDistance2dSq( go ) > EOTS_CAPTURE_DISTANCE )
			{
				disp->erase( eitr2 );
				plr->SendWorldStateUpdate(EOTS_WORLDSTATE_DISPLAYON, 0);			// hide the cp bar
			}
			else
				plr->SendWorldStateUpdate(EOTS_WORLDSTATE_DISPLAYVALUE, m_CPStatus[i]);
		}
	}

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

	SetWorldState( EOTS_WORLDSTATE_ALLIANCE_BASES, towers[0] );
	SetWorldState( EOTS_WORLDSTATE_HORDE_BASES, towers[1] );
}