Пример #1
0
        void OnSpawn()
        {
            MapMgr* mgr = _gameobject->GetMapMgr();
            Player* plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ());

            m_bannerStatus = BANNER_STATUS_NEUTRAL;

            // preloaded data, do we have any?
            if(TFg_towerOwners[towerid] == 1)
            {
                m_bannerStatus = BANNER_STATUS_HORDE;
                Status = 0;

                // state update
                mgr->GetWorldStatesHandler().SetWorldStateForZone(ZONE_TEROKKAR_FOREST, mgr->GetAreaID( _gameobject->GetPositionX(), _gameobject->GetPositionY() ), g_hordeStateFields[towerid], 1);
                mgr->GetWorldStatesHandler().SetWorldStateForZone(ZONE_TEROKKAR_FOREST, mgr->GetAreaID( _gameobject->GetPositionX(), _gameobject->GetPositionY() ), g_neutralStateFields[towerid], 0);

                // countz
                TFg_hordeTowers++;
                UpdateTowerCount();
                SetArtKit();
            }
            else if(TFg_towerOwners[towerid] == 0)
            {
                m_bannerStatus = BANNER_STATUS_ALLIANCE;
                Status = 100;

                // state update
                mgr->GetWorldStatesHandler().SetWorldStateForZone(ZONE_TEROKKAR_FOREST, mgr->GetAreaID( _gameobject->GetPositionX(), _gameobject->GetPositionY() ), g_allianceStateFields[towerid], 1);
                mgr->GetWorldStatesHandler().SetWorldStateForZone(ZONE_TEROKKAR_FOREST, mgr->GetAreaID( _gameobject->GetPositionX(), _gameobject->GetPositionY() ), g_neutralStateFields[towerid], 0);

                // countz
                TFg_allianceTowers++;
                UpdateTowerCount();
                SetArtKit();
            }

            // start the event timer
            RegisterAIUpdateEvent(UPDATE_PERIOD);
        }
Пример #2
0
	void OnSpawn()
	{
		m_bannerStatus = BANNER_STATUS_NEUTRAL;

		// preloaded data, do we have any?
		if( g_towerOwners[towerid] == 1 )
		{
			m_bannerStatus = BANNER_STATUS_HORDE;
			Status = 0;

			// state update
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_hordeStateFields[towerid], 1);
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_neutralStateFields[towerid], 0);

			// countz
			g_hordeTowers++;
			UpdateTowerCount(_gameobject->GetMapMgr());
			SetArtKit();
		}
		else if( g_towerOwners[towerid] == 0 )
		{
			m_bannerStatus = BANNER_STATUS_ALLIANCE;
			Status = 100;

			// state update
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_allianceStateFields[towerid], 1);
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_neutralStateFields[towerid], 0);

			// countz
			g_allianceTowers++;
			UpdateTowerCount(_gameobject->GetMapMgr());
			SetArtKit();
		}

		// start the event timer
		RegisterAIUpdateEvent(UPDATE_PERIOD);
	}
Пример #3
0
	void SetupGo(MapMgr * pMapMgr)
	{
		m_bannerStatus = BANNER_STATUS_NEUTRAL;

		// preloaded data, do we have any?
		if(g_towerOwners[m_towerid] == 1)
		{
			m_bannerStatus = BANNER_STATUS_HORDE;
			m_Status = 0;

			// state update
			pMapMgr->GetWorldStateManager()->SetWorldState(g_hordeStateFields[m_towerid], 1);
			pMapMgr->GetWorldStateManager()->SetWorldState(g_neutralStateFields[m_towerid], 0);

			// countz
			g_hordeTowers++;
			UpdateTowerCount(pMapMgr);
			SetArtKit();
		}
		else if(g_towerOwners[m_towerid] == 0)
		{
			m_bannerStatus = BANNER_STATUS_ALLIANCE;
			m_Status = 100;

			// state update
			pMapMgr->GetWorldStateManager()->SetWorldState(g_allianceStateFields[m_towerid], 1);
			pMapMgr->GetWorldStateManager()->SetWorldState(g_neutralStateFields[m_towerid], 0);

			// countz
			g_allianceTowers++;
			UpdateTowerCount(pMapMgr);
			SetArtKit();
		}

		// start the event timer
		RegisterAIUpdateEvent(UPDATE_PERIOD);
	}
Пример #4
0
	void AIUpdate()
	{
		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

		set<Player*>::iterator itr = _gameobject->GetInRangePlayerSetBegin();		
		set<Player*>::iterator itrend = _gameobject->GetInRangePlayerSetEnd();
		map<uint32,uint32>::iterator it2, it3;
		uint32 timeptr = (uint32)UNIXTIME;
		bool in_range;
		bool is_valid;
		Player *plr;
		
		for(; itr != itrend; ++itr)
		{
			if( !(*itr)->IsPvPFlagged() || (*itr)->IsStealth() )
				is_valid = false;
			else
				is_valid = true;

			in_range = (_gameobject->GetDistanceSq((*itr)) <= BANNER_RANGE) ? true : false;

			it2 = StoredPlayers.find((*itr)->GetLowGUID());
			if( it2 == StoredPlayers.end() )
			{
				// new player :)
				if( in_range )
				{
					(*itr)->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_DISPLAY, 1);
					(*itr)->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_VALUE, Status);
					StoredPlayers.insert(make_pair((*itr)->GetLowGUID(), timeptr));

					if( is_valid )
						plrcounts[(*itr)->GetTeam()]++;
				}
			}
			else
			{
				// oldie
				if( !in_range )
				{
					(*itr)->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_DISPLAY, 0);
					StoredPlayers.erase(it2);
				}
				else
				{
					(*itr)->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_VALUE, Status);
					it2->second = timeptr;
					if( is_valid )
						plrcounts[(*itr)->GetTeam()]++;
				}
			}
		}

		// handle stuff for the last tick
		if( Status == 100 && m_bannerStatus != BANNER_STATUS_ALLIANCE )
		{
			m_bannerStatus = BANNER_STATUS_ALLIANCE;
			SetArtKit();

			// send message to everyone in the zone, has been captured by the Alliance
			_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00%s has been taken by the Alliance!|r", ControlPointName);

			// tower update
			g_allianceTowers++;
			UpdateTowerCount(_gameobject->GetMapMgr());

			// state update
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_neutralStateFields[towerid], 0);
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_allianceStateFields[towerid], 1);

			// woot
			g_towerOwners[towerid] = 1;
			UpdateInDB();
		}
		else if( Status == 0 && m_bannerStatus != BANNER_STATUS_HORDE )
		{
			m_bannerStatus = BANNER_STATUS_HORDE;
			SetArtKit();

			// send message to everyone in the zone, has been captured by the Horde
			_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00%s has been taken by the Horde!|r", ControlPointName);
			
			// tower update
			g_hordeTowers++;
			UpdateTowerCount(_gameobject->GetMapMgr());

			// state update
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_neutralStateFields[towerid], 0);
			_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_hordeStateFields[towerid], 1);

			// woot
			g_towerOwners[towerid] = 0;
			UpdateInDB();
		}
		else if( m_bannerStatus != BANNER_STATUS_NEUTRAL )
		{
			// if the difference for the faction is >50, change to neutral
			if( m_bannerStatus == BANNER_STATUS_ALLIANCE && Status <= 50 )
			{
				// send message: The Alliance has lost control of point xxx
				m_bannerStatus = BANNER_STATUS_NEUTRAL;
				SetArtKit();
				
				g_allianceTowers--;
				UpdateTowerCount(_gameobject->GetMapMgr());

				_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00The Alliance have lost control of %s!|r", ControlPointName);

				// state update
				_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_allianceStateFields[towerid], 0);
				_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_neutralStateFields[towerid], 1);

				// woot
				g_towerOwners[towerid] = -1;
				UpdateInDB();
			}
			else if( m_bannerStatus == BANNER_STATUS_HORDE && Status >= 50 )
			{
				// send message: The Alliance has lost control of point xxx
				m_bannerStatus = BANNER_STATUS_NEUTRAL;
				SetArtKit();

				g_hordeTowers--;
				UpdateTowerCount(_gameobject->GetMapMgr());

				_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00The Horde have lost control of %s!|r", ControlPointName);

				// state update
				_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_hordeStateFields[towerid], 0);
				_gameobject->GetMapMgr()->GetStateManager().UpdateWorldState(g_neutralStateFields[towerid], 1);

				// woot
				g_towerOwners[towerid] = -1;
				UpdateInDB();
			}
		}

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

			if( it3->second != timeptr )
			{
				plr = _gameobject->GetMapMgr()->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_HELLFIRE_PVP_CAPTURE_BAR_DISPLAY, 0);

				StoredPlayers.erase(it3);
			}
		}

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

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

			Status += delta;
			if( Status >= 100 )
				Status = 100;
		}
		else if( plrcounts[1] > plrcounts[0] )
		{
			delta = plrcounts[1] - plrcounts[0];
			delta *= CAPTURE_RATE;
			
			// cap it at 25 so the banner always gets removed.
			if( delta > 25 )
				delta = 25;

			if( delta > Status )
				Status = 0;
			else
				Status -= delta;
		}
	}
Пример #5
0
	void AIUpdate()
	{
		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
		map<uint32,uint32>::iterator it2, it3;
		uint32 timeptr = static_cast<uint32>(UNIXTIME);
		bool in_range = false;
		bool is_valid = false;
		
		for(PlayerSet::const_iterator itr = _gameobject->GetInRangePlayerSetBegin();itr != _gameobject->GetInRangePlayerSetEnd();)
		{
			Player * plr = (*itr);
			++itr;

			if(!plr->IsPvPFlagged() || plr->IsStealth())
				is_valid = false;
			else
				is_valid = true;

			in_range = (_gameobject->GetDistanceSq(plr) <= BANNER_RANGE) ? true : false;

			it2 = m_StoredPlayers.find(plr->GetLowGUID());
			if(it2 == m_StoredPlayers.end())
			{
				// new player :)
				if(in_range)
				{
					plr->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_DISPLAY, 1);
					plr->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_VALUE, m_Status);
					m_StoredPlayers.insert(make_pair(plr->GetLowGUID(), timeptr));

					if(is_valid)
					{
						plrcounts[plr->GetTeam()]++;
					}
				}
			}
			else
			{
				// oldie
				if(!in_range)
				{
					plr->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_DISPLAY, 0);
					m_StoredPlayers.erase(it2);
				}
				else
				{
					plr->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_VALUE, m_Status);
					it2->second = timeptr;
					if(is_valid)
					{
						plrcounts[plr->GetTeam()]++;
					}
				}
			}
		}

		// handle stuff for the last tick
		if(m_Status == 100 && m_bannerStatus != BANNER_STATUS_ALLIANCE)
		{
			m_bannerStatus = BANNER_STATUS_ALLIANCE;
			SetArtKit();

			// send message to everyone in the zone, has been captured by the Alliance
			_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00%s has been taken by the Alliance!|r", m_ControlPointName.c_str());

			// tower update
			g_allianceTowers++;
			UpdateTowerCount(_gameobject->GetMapMgr());

			// state update
			_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_neutralStateFields[m_towerid], 0);
			_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_allianceStateFields[m_towerid], 1);

			// woot
			g_towerOwners[m_towerid] = 1;
			UpdateInDB();

			//Hellfire Fortifications - complete objective
																					
			for(PlayerSet::iterator itr = _gameobject->GetInRangePlayerSetBegin();itr != _gameobject->GetInRangePlayerSetEnd();)  
			{																											
				Player * pPlr = (*itr);																					
				++itr;	
				{
					if(pPlr->GetTeam() == HORDE && pPlr->HasQuest(10106))
					{
						QuestLogEntry * pQLE = pPlr->GetQuestLogForEntry(10106);
						if(pQLE && pQLE->GetMobCount(m_towerid) == 0)
						{
							pQLE->SetMobCount(m_towerid, 1);
							pQLE->SendUpdateAddKill(m_towerid);
							pQLE->UpdatePlayerFields();
						}
					}
				}
			}
		}
		else if(m_Status == 0 && m_bannerStatus != BANNER_STATUS_HORDE)
		{
			m_bannerStatus = BANNER_STATUS_HORDE;
			SetArtKit();

			// send message to everyone in the zone, has been captured by the Horde
			_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00%s has been taken by the Horde!|r", m_ControlPointName.c_str());
			
			// tower update
			g_hordeTowers++;
			UpdateTowerCount(_gameobject->GetMapMgr());

			// state update
			_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_neutralStateFields[m_towerid], 0);
			_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_hordeStateFields[m_towerid], 1);

			// woot
			g_towerOwners[m_towerid] = 0;
			UpdateInDB();
			//Hellfire Fortifications - complete objective			
			
			for(PlayerSet::iterator itr = _gameobject->GetInRangePlayerSetBegin();itr != _gameobject->GetInRangePlayerSetEnd();)  
			{																											
				Player * pPlr = (*itr);																					
				++itr;	
				{
					if(pPlr->GetTeam() == HORDE && pPlr->HasQuest(10110))
					{
						QuestLogEntry * pQLE = pPlr->GetQuestLogForEntry(10110);
						if(pQLE && pQLE->GetMobCount(m_towerid) == 0)
						{
							pQLE->SetMobCount(m_towerid, 1);
							pQLE->SendUpdateAddKill(m_towerid);
							pQLE->UpdatePlayerFields();
						}
					}
				}
			}
		}
		else if(m_bannerStatus != BANNER_STATUS_NEUTRAL)
		{
			// if the difference for the faction is >50, change to neutral
			if(m_bannerStatus == BANNER_STATUS_ALLIANCE && m_Status <= 50)
			{
				// send message: The Alliance has lost control of point xxx
				m_bannerStatus = BANNER_STATUS_NEUTRAL;
				SetArtKit();
				
				g_allianceTowers--;
				UpdateTowerCount(_gameobject->GetMapMgr());

				_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00The Alliance have lost control of %s!|r", m_ControlPointName.c_str());

				// state update
				_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_allianceStateFields[m_towerid], 0);
				_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_neutralStateFields[m_towerid], 1);

				// woot
				g_towerOwners[m_towerid] = -1;
				UpdateInDB();
			}
			else if(m_bannerStatus == BANNER_STATUS_HORDE && m_Status >= 50)
			{
				// send message: The Alliance has lost control of point xxx
				m_bannerStatus = BANNER_STATUS_NEUTRAL;
				SetArtKit();

				g_hordeTowers--;
				UpdateTowerCount(_gameobject->GetMapMgr());

				_gameobject->GetMapMgr()->SendPvPCaptureMessage(ZONE_HELLFIRE_PENINSULA, ZONE_HELLFIRE_PENINSULA, "|cffffff00The Horde have lost control of %s!|r", m_ControlPointName.c_str());

				// state update
				_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_hordeStateFields[m_towerid], 0);
				_gameobject->GetMapMgr()->GetWorldStateManager()->SetWorldState(g_neutralStateFields[m_towerid], 1);

				// woot
				g_towerOwners[m_towerid] = -1;
				UpdateInDB();
			}
		}

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

			if(it3->second != timeptr)
			{
				Player * plr = _gameobject->GetMapMgr()->GetPlayer(it3->first);
				if(plr != NULL)
				{
					plr->SendWorldStateUpdate(WORLDSTATE_HELLFIRE_PVP_CAPTURE_BAR_DISPLAY, 0);
				}
				m_StoredPlayers.erase(it3);
			}
		}

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

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

			m_Status += delta;
			if(m_Status >= 100)
				m_Status = 100;
		}
		else if(plrcounts[1] > plrcounts[0])
		{
			delta = plrcounts[1] - plrcounts[0];
			delta *= CAPTURE_RATE;
			
			// cap it at 25 so the banner always gets removed.
			if(delta > 25)
				delta = 25;

			if(delta > m_Status)
				m_Status = 0;
			else
				m_Status -= delta;
		}
	}