void WintergraspWorkshopData::OnBattleStart()
{
    // Update graveyard
    UpdateGraveyard();

    // Show Engineer
    if (Creature* pEngineer = m_WG->GetCreature(m_Engineer[m_TeamControl]))
        m_WG->ShowNpc(pEngineer, false);

    if (m_workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
    {
        // Reset creatures
        for (GuidSet::const_iterator itr = m_CreatureOnPoint[m_TeamControl].begin(); itr != m_CreatureOnPoint[m_TeamControl].end(); ++itr)
            if (Creature* pCreature = m_WG->GetCreature(*itr))
                pCreature->SetPosition(pCreature->GetHomePosition());

        // Show rocket launchers
        for (GuidSet::const_iterator itr = m_RocketLauncherOnPoint.begin(); itr != m_RocketLauncherOnPoint.end(); ++itr)
        {
            if (Creature* pCreature = m_WG->GetCreature(*itr))
            {
                m_WG->ShowNpc(pCreature, false);
                pCreature->setFaction(WintergraspFaction[GetTeam()]);
            }
        }

        // Spawning Factory Banner
        WintergraspObjectPositionData factory = CapturableWorkshops[m_workshopId].GameObjectMain[1];
        GameObject* pFactory = m_WG->SpawnGameObject(factory.entryHorde, factory.x, factory.y, factory.z, factory.o);
        if (!pFactory)
            return;

        // Create and Add Capturable Point
        WintergraspCapturePoint* capturePoint = new WintergraspCapturePoint(m_WG, TeamId(m_TeamControl));
        if (!capturePoint)
            return;

        capturePoint->SetCapturePointData(pFactory);
        capturePoint->LinkToWorkshop(this);
        m_WG->AddCapturablePoint(capturePoint);

        // Save factory banner guid and entry
        m_FactoryGUID = pFactory->GetGUID();
        m_FactoryEntry = pFactory->GetEntry();

        // Update GameObject ArtKit of the Factory Banner (only outside workshops)
        GameObject::SetGoArtKit(m_TeamControl ? GO_ARTKIT_FACTORY_HORDE : GO_ARTKIT_FACTORY_ALLIANCE, pFactory, pFactory->GetGUIDLow());
    }
}
Esempio n. 2
0
void OPvPWintergrasp::EndBattle()
{
    m_wartime = false;
    m_timer = sWorld.getConfig(CONFIG_OUTDOORPVP_WINTERGRASP_INTERVAL) * MINUTE * IN_MILISECONDS;

    for(uint32 team = 0; team < 2; ++team)
    {
        VehicleCastSpell(TeamId(team), SPELL_SHUTDOWN_VEHICLE);

        for(PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
        {
            REMOVE_RANK_AURAS(*itr);
        }
    }
}
bool BattlefieldWG::SetupBattlefield()
{
    m_TypeId = BATTLEFIELD_WG;                              // See enum BattlefieldTypes
    m_BattleId = BATTLEFIELD_BATTLEID_WG;
    m_ZoneId = BATTLEFIELD_WG_ZONEID;
    m_MapId = BATTLEFIELD_WG_MAPID;
    m_Map = sMapMgr->FindMap(m_MapId, 0);

    InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]);

    m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MAX);
    m_IsEnabled = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE);
    m_MinPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN);
    m_MinLevel = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN_LVL);
    m_BattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_BATTLETIME) * MINUTE * IN_MILLISECONDS;
    m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_NOBATTLETIME) * MINUTE * IN_MILLISECONDS;
    m_RestartAfterCrash = sWorld->getIntConfig(CONFIG_WINTERGRASP_RESTART_AFTER_CRASH) * MINUTE * IN_MILLISECONDS;

    m_TimeForAcceptInvite = 20;
    m_StartGroupingTimer = 15 * MINUTE * IN_MILLISECONDS;
    m_StartGrouping = false;

    m_tenacityStack = 0;

    KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
    KickPosition.m_mapId = m_MapId;

    RegisterZone(m_ZoneId);

    m_Data32.resize(BATTLEFIELD_WG_DATA_MAX);

    m_saveTimer = 60000;

    // Init GraveYards
    SetGraveyardNumber(BATTLEFIELD_WG_GRAVEYARD_MAX);

    // Load from db
    if ((sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) == 0) && (sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) == 0)
            && (sWorld->getWorldState(ClockWorldState[0]) == 0))
    {
        sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false));
        sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, uint64(urand(0, 1)));
        sWorld->setWorldState(ClockWorldState[0], uint64(m_NoWarBattleTime));
    }

    m_isActive = bool(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE));
    m_DefenderTeam = TeamId(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER));

    m_Timer = sWorld->getWorldState(ClockWorldState[0]);
    if (m_isActive)
    {
        m_isActive = false;
        m_Timer = m_RestartAfterCrash;
    }

    for (uint8 i = 0; i < BATTLEFIELD_WG_GRAVEYARD_MAX; i++)
    {
        BfGraveyardWG* graveyard = new BfGraveyardWG(this);

        // When between games, the graveyard is controlled by the defending team
        if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL)
            graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].gyid);
        else
            graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);

        graveyard->SetTextId(WGGraveYard[i].textid);
        m_GraveyardList[i] = graveyard;
    }


    // Spawn workshop creatures and gameobjects
    for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++)
    {
        WGWorkshop* workshop = new WGWorkshop(this, i);
        if (i < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
            workshop->GiveControlTo(GetAttackerTeam(), true);
        else
            workshop->GiveControlTo(GetDefenderTeam(), true);

        // Note: Capture point is added once the gameobject is created.
        WorkshopsList.insert(workshop);
    }

    // Spawn NPCs in the defender's keep, both Horde and Alliance
    for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++)
    {
        // Horde npc
        if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryHorde, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE))
            KeepCreature[TEAM_HORDE].insert(creature->GetGUID());
        // Alliance npc
        if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryAlliance, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE))
            KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
    }

    // Hide NPCs from the Attacker's team in the keep
    for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
        if (Creature* creature = GetCreature(*itr))
            HideNpc(creature);

    // Spawn Horde NPCs outside the keep
    for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++)
        if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryHorde, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE))
            OutsideCreature[TEAM_HORDE].insert(creature->GetGUID());

    // Spawn Alliance NPCs outside the keep
    for (uint8 i = WG_OUTSIDE_ALLIANCE_NPC; i < WG_MAX_OUTSIDE_NPC; i++)
        if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryAlliance, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE))
            OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID());

    // Hide units outside the keep that are defenders
    for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
        if (Creature* creature = GetCreature(*itr))
            HideNpc(creature);

    // Spawn turrets and hide them per default
    for (uint8 i = 0; i < WG_MAX_TURRET; i++)
    {
        Position towerCannonPos = WGTurret[i].GetPosition();
        if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
        {
            CanonList.insert(creature->GetGUID());
            HideNpc(creature);
        }
    }

    // Spawn all gameobjects
    for (uint8 i = 0; i < WG_MAX_OBJ; i++)
    {
        if (GameObject* go = SpawnGameObject(WGGameObjectBuilding[i].entry, WGGameObjectBuilding[i].x, WGGameObjectBuilding[i].y, WGGameObjectBuilding[i].z, WGGameObjectBuilding[i].o))
        {
            BfWGGameObjectBuilding* b = new BfWGGameObjectBuilding(this);
            b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].nameId);
            if (!IsEnabled() && go->GetEntry() == GO_WINTERGRASP_VAULT_GATE)
                go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED);
            BuildingsInZone.insert(b);
        }
    }

    // Spawning portal defender
    for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++)
    {
        if (GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o))
        {
            DefenderPortalList.insert(go->GetGUID());
            go->SetFaction(WintergraspFaction[GetDefenderTeam()]);
        }
    }

    UpdateCounterVehicle(true);
    return true;
}
Esempio n. 4
0
bool OPvPWintergrasp::SetupOutdoorPvP()
{
    m_defender = TeamId(rand()%2);

    // Load buildings
    AreaPOIList areaPOIs;
    float minX = 9999, minY = 9999, maxX = -9999, maxY = -9999;
    for(uint32 i = 0; i < sAreaPOIStore.GetNumRows(); ++i)
    {
        const AreaPOIEntry * poiInfo = sAreaPOIStore.LookupEntry(i);
        if(poiInfo && poiInfo->zoneId == ZONE_WINTERGRASP)
        {
            areaPOIs.push_back(poiInfo);
            if(minX > poiInfo->x) minX = poiInfo->x;
            if(minY > poiInfo->y) minY = poiInfo->y;
            if(maxX < poiInfo->x) maxX = poiInfo->x;
            if(maxY < poiInfo->y) maxY = poiInfo->y;
        }
    }
    minX -= 20; minY -= 20; maxX += 20; maxY += 20;

    QueryResult *result = WorldDatabase.PQuery("SELECT `guid` FROM `gameobject`,`gameobject_template`"
        " WHERE `gameobject`.`map`=571"
        " AND `gameobject`.`position_x`>%f AND `gameobject`.`position_y`>%f"
        " AND `gameobject`.`position_x`<%f AND `gameobject`.`position_y`<%f"
        " AND `gameobject_template`.`type`=33"
        " AND `gameobject`.`id`=`gameobject_template`.`entry`",
        minX, minY, maxX, maxY);
    if(!result)
        return false;

    do
    {
        Field *fields = result->Fetch();
        
        uint32 guid = fields[0].GetUInt32();
        GameObjectData const * goData = objmgr.GetGOData(guid);
        if(!goData) // this should not happen
            continue;

        float x = goData->posX, y = goData->posY;
        float minDist = 100;
        AreaPOIList::iterator poi = areaPOIs.end();
        for(AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end(); ++itr)
        {
            if(!(*itr)->icon[1]) // note: may for other use
                continue;

            float dist = (abs((*itr)->x - x) + abs((*itr)->y - y));
            if(minDist > dist)
            {
                minDist = dist;
                poi = itr;
            }
        }

        if(poi == areaPOIs.end())
            continue;

        // add building to the list
        TeamId teamId = x > POS_X_CENTER ? m_defender : OTHER_TEAM(m_defender);
        m_buildingStates[guid] = new BuildingState((*poi)->worldState, teamId, m_defender != TEAM_ALLIANCE);
        areaPOIs.erase(poi);

        //disable for now
        //continue;

        // add capture point
        uint32 capturePointEntry = 0;

        //192028 192029
        //192030 192031
        //192032 192033

        //190475 190487 not sure
        //192626 192627
        //194959 194960

        switch(goData->id)
        {
            case 192028: capturePointEntry = 190475; break;
            case 192029: capturePointEntry = 190487; break;
            case 192030: capturePointEntry = 190475; break;
            case 192031: capturePointEntry = 190487; break;
            case 192032: capturePointEntry = 190475; break;
            case 192033: capturePointEntry = 190487; break;
        }
        if(capturePointEntry)
        {
            uint32 engGuid = 0;

            QueryResult *result = WorldDatabase.PQuery("SELECT `guid` FROM `creature`"
                " WHERE `creature`.`map`=571"
                " AND `creature`.`id` IN (%u, %u);", CRE_ENG_A, CRE_ENG_H);

            if(!result)
            {
                sLog.outError("Cannot find siege workshop master in creature!"); 
                continue;
            }

            float minDist = 100;
            do
            {
                Field *fields = result->Fetch();
                uint32 guid = fields[0].GetUInt32();
                const CreatureData *creData = objmgr.GetCreatureData(guid);
                if(!creData)
                    continue;

                float dist = (abs(creData->posX - x) + abs(creData->posY - y));
                if(minDist > dist)
                {
                    minDist = dist;
                    engGuid = guid;
                }
            }while(result->NextRow());
            delete result;

            if(!engGuid)
            {
                sLog.outError("Cannot find nearby siege workshop master!");
                continue;
            }

            SiegeWorkshop *workshop = new SiegeWorkshop(this, m_buildingStates[guid]);
            if(!workshop->SetCapturePointData(capturePointEntry, goData->mapid, goData->posX, goData->posY, goData->posZ))
            {
                delete workshop;
                sLog.outError("Cannot add capture point!");
                continue;
            }
            const CreatureData *creData = objmgr.GetCreatureData(engGuid);
            if(!creData)
                continue;

            workshop->m_engEntry = const_cast<uint32*>(&creData->id);
            const_cast<CreatureData*>(creData)->displayid = 0;
            workshop->m_workshopGuid = guid;
            workshop->m_engGuid = engGuid;
            //workshop->AddGO(0, guid, goData->id);
            //workshop->AddCre(0, engGuid, creData->id);
            //sLog.outDebug("Demolisher Engineerer lowguid %u is linked to workshop lowguid %u.", engGuid, guid);
            AddCapturePoint(workshop);
            m_buildingStates[guid]->type = BUILDING_WORKSHOP;
            workshop->SetStateByBuildingState();
        }
    }while(result->NextRow());
    delete result;

    //for(AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end(); ++itr)
    //    sLog.outError("not assigned %u %f %f", (*itr)->id, (*itr)->x, (*itr)->y);

    //gameeventmgr.StartInternalEvent(GameEventWintergraspDefender[m_defender]);

    //Titan Relic eventid = 19982
    objmgr.AddGOData(192829, 571, 5440, 2840.8, 420.43, 0);

    LoadTeamPair(m_goDisplayPair, GODisplayPair);
    LoadTeamPair(m_creEntryPair, CreatureEntryPair);

    m_wartime = false;
    m_timer = sWorld.getConfig(CONFIG_OUTDOORPVP_WINTERGRASP_START_TIME) * MINUTE * IN_MILISECONDS;

    RegisterZone(ZONE_WINTERGRASP);
    return true;
}
Esempio n. 5
0
void BattlegroundAB::PostUpdateImpl(uint32 diff)
{
    if (GetStatus() == STATUS_IN_PROGRESS)
    {
		_bgEvents.Update(diff);
		while (uint32 eventId =_bgEvents.ExecuteEvent())
			switch (eventId)
			{
				case BG_AB_EVENT_UPDATE_BANNER_STABLE:
				case BG_AB_EVENT_UPDATE_BANNER_FARM:
				case BG_AB_EVENT_UPDATE_BANNER_BLACKSMITH:
				case BG_AB_EVENT_UPDATE_BANNER_LUMBERMILL:
				case BG_AB_EVENT_UPDATE_BANNER_GOLDMINE:
					CreateBanner(eventId - BG_AB_EVENT_UPDATE_BANNER_STABLE, false);
					break;
				case BG_AB_EVENT_CAPTURE_STABLE:
				case BG_AB_EVENT_CAPTURE_FARM:
				case BG_AB_EVENT_CAPTURE_BLACKSMITH:
				case BG_AB_EVENT_CAPTURE_LUMBERMILL:
				case BG_AB_EVENT_CAPTURE_GOLDMINE:
				{
					uint8 node = eventId - BG_AB_EVENT_CAPTURE_STABLE;
					TeamId teamId = _capturePointInfo[node]._state == BG_AB_NODE_STATE_ALLY_CONTESTED ? TEAM_ALLIANCE : TEAM_HORDE;
					DeleteBanner(node);
					_capturePointInfo[node]._ownerTeamId = teamId;
					_capturePointInfo[node]._state = teamId == TEAM_ALLIANCE ? BG_AB_NODE_STATE_ALLY_OCCUPIED : BG_AB_NODE_STATE_HORDE_OCCUPIED;
					_capturePointInfo[node]._captured = true;

                    CreateBanner(node, false);
                    NodeOccupied(node);
                    SendNodeUpdate(node);

					SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, teamId == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, NULL, teamId == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE, LANG_BG_AB_NODE_STABLES + node);
					PlaySoundToAll(teamId == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_CAPTURED_ALLIANCE : BG_AB_SOUND_NODE_CAPTURED_HORDE);
					break;
				}
				case BG_AB_EVENT_ALLIANCE_TICK:
				case BG_AB_EVENT_HORDE_TICK:
				{
					TeamId teamId = TeamId(eventId - BG_AB_EVENT_ALLIANCE_TICK);
					uint8 controlledPoints = _controlledPoints[teamId];
					if (controlledPoints == 0)
					{
						_bgEvents.ScheduleEvent(eventId, 3000);
						break;
					}

					uint8 honorRewards = uint8(m_TeamScores[teamId] / _honorTics);
					uint8 reputationRewards = uint8(m_TeamScores[teamId] / _reputationTics);
					uint8 information = uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE);
					m_TeamScores[teamId] += BG_AB_TickPoints[controlledPoints];
					if (m_TeamScores[teamId] > BG_AB_MAX_TEAM_SCORE)
						m_TeamScores[teamId] = BG_AB_MAX_TEAM_SCORE;

					if (honorRewards < uint8(m_TeamScores[teamId] / _honorTics))
						RewardHonorToTeam(GetBonusHonorFromKill(1), teamId);
					if (reputationRewards < uint8(m_TeamScores[teamId] / _reputationTics))
						RewardReputationToTeam(teamId == TEAM_ALLIANCE ? 509 : 510, 10, teamId);
					if (information < uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE))
					{
						SendMessageToAll(teamId == TEAM_ALLIANCE ? LANG_BG_AB_A_NEAR_VICTORY : LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
						PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY);
					}

					UpdateWorldState(teamId == TEAM_ALLIANCE ? BG_AB_OP_RESOURCES_ALLY : BG_AB_OP_RESOURCES_HORDE, m_TeamScores[teamId]);
					if (m_TeamScores[teamId] > m_TeamScores[GetOtherTeamId(teamId)] + 500)
						_teamScores500Disadvantage[GetOtherTeamId(teamId)] = true;
					if (m_TeamScores[teamId] >= BG_AB_MAX_TEAM_SCORE)
						EndBattleground(teamId);

					_bgEvents.ScheduleEvent(eventId, BG_AB_TickIntervals[controlledPoints]);
					break;
				}
			}
	}
}
Esempio n. 6
0
bool BattlefieldTB::SetupBattlefield()
{
    m_TypeId = BATTLEFIELD_TB;                              // See enum BattlefieldTypes
    m_BattleId = BATTLEFIELD_BATTLEID_TB;
    m_ZoneId = BATTLEFIELD_TB_ZONEID;
    m_MapId = BATTLEFIELD_TB_MAPID;
    m_Map = sMapMgr->CreateBaseMap(m_MapId);

    InitStalker(NPC_DEBUG_ANNOUNCER, TolBaradDebugAnnouncerPos);

    m_MaxPlayer = sWorld->getIntConfig(CONFIG_TOLBARAD_PLR_MAX);
    m_IsEnabled = sWorld->getBoolConfig(CONFIG_TOLBARAD_ENABLE);
    m_MinPlayer = sWorld->getIntConfig(CONFIG_TOLBARAD_PLR_MIN);
    m_MinLevel = sWorld->getIntConfig(CONFIG_TOLBARAD_PLR_MIN_LVL);
    m_BattleTime = sWorld->getIntConfig(CONFIG_TOLBARAD_BATTLETIME) * MINUTE * IN_MILLISECONDS;
    m_BonusTime = sWorld->getIntConfig(CONFIG_TOLBARAD_BONUSTIME) * MINUTE * IN_MILLISECONDS;
    m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_TOLBARAD_NOBATTLETIME) * MINUTE * IN_MILLISECONDS;
    m_RestartAfterCrash = sWorld->getIntConfig(CONFIG_TOLBARAD_RESTART_AFTER_CRASH) * MINUTE * IN_MILLISECONDS;

    m_TimeForAcceptInvite = 20;
    m_StartGroupingTimer = 15 * MINUTE * IN_MILLISECONDS;
    m_StartGrouping = false;
    m_isActive = false;

    KickPosition.Relocate(-605.5f, 1181.31f, 95.96f, 6.177155f);
    KickPosition.m_mapId = m_MapId;

    RegisterZone(m_ZoneId);

    m_Data32.resize(BATTLEFIELD_TB_DATA_MAX);

    m_saveTimer = 5 * MINUTE * IN_MILLISECONDS;

    updatedNPCAndObjects = true;
    m_updateObjectsTimer = 0;

    // Was there a battle going on or time isn't set yet? Then use m_RestartAfterCrash
    if (sWorld->getWorldState(TB_WS_STATE_BATTLE) == 1 || sWorld->getWorldState(TB_WS_TIME_NEXT_BATTLE) == 0)
        sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE, m_RestartAfterCrash);

    // Set timer
    m_Timer = sWorld->getWorldState(TB_WS_TIME_NEXT_BATTLE);

    // Defending team isn't set yet? Choose randomly.
    if (sWorld->getWorldState(TB_WS_FACTION_CONTROLLING) == 0)
        sWorld->setWorldState(TB_WS_FACTION_CONTROLLING, uint32(urand(1, 2)));

    // Set defender team
    SetDefenderTeam(TeamId(sWorld->getWorldState(TB_WS_FACTION_CONTROLLING) - 1));

    // Just to save world states
    SendInitWorldStatesToAll();

    // Create capture points
    for (uint8 i = 0; i < TB_BASE_COUNT; i++)
    {
        TolBaradCapturePoint* capturePoint = new TolBaradCapturePoint(this, GetDefenderTeam());

        //Spawn flag pole
        if (GameObject* go = SpawnGameObject(TBCapturePoints[i].entryFlagPole[GetDefenderTeam()], TBCapturePoints[i].pos, QuaternionData()))
        {
            go->SetGoArtKit(GetDefenderTeam() == TEAM_ALLIANCE ? TB_GO_ARTKIT_FLAG_ALLIANCE : TB_GO_ARTKIT_FLAG_HORDE);
            capturePoint->SetCapturePointData(go);
        }
        AddCapturePoint(capturePoint);
    }

    // Spawn towers
    for (uint8 i = 0; i < TB_TOWERS_COUNT; i++)
        if (GameObject* go = SpawnGameObject(TBTowers[i].entry, TBTowers[i].pos, QuaternionData()))
            Towers.insert(go->GetGUID());

    // Init Graveyards
    SetGraveyardNumber(BATTLEFIELD_TB_GRAVEYARD_MAX);

    // Graveyards
    for (uint8 i = 0; i < BATTLEFIELD_TB_GRAVEYARD_MAX; i++)
    {
        BfGraveyard* graveyard = new BfGraveyard(this);

        // When between games, the graveyard is controlled by the defending team
        graveyard->Initialize(GetDefenderTeam(), TBGraveyards[i].gyid);

        // Spawn spirits
        for (uint8 team = 0; team < 2; team++)
            if (Creature* creature = SpawnCreature(TBGraveyards[i].spiritEntry[team], TBGraveyards[i].pos))
                graveyard->SetSpirit(creature, TeamId(team));

        m_GraveyardList[i] = graveyard;
    }

    // Time warning vars
    warnedFiveMinutes = false;
    warnedTwoMinutes = false;
    warnedOneMinute = false;

    UpdateNPCsAndGameObjects();

    return true;
}
Esempio n. 7
0
bool OPvPWintergrasp::SetupOutdoorPvP()
{
    if(!sWorld.getConfig(CONFIG_OUTDOORPVP_WINTERGRASP_ENABLED))
        return false;

    m_defender = TeamId(rand()%2);
    m_changeDefender = false;

    m_workshopCount[TEAM_ALLIANCE] = 0;
    m_workshopCount[TEAM_HORDE] = 0;
    m_towerCount = 3;

    // Select POI
    AreaPOIList areaPOIs;
    float minX = 9999, minY = 9999, maxX = -9999, maxY = -9999;
    for (uint32 i = 0; i < sAreaPOIStore.GetNumRows(); ++i)
    {
        const AreaPOIEntry * poiInfo = sAreaPOIStore.LookupEntry(i);
        if (poiInfo && poiInfo->zoneId == ZONE_WINTERGRASP)
        {
            areaPOIs.push_back(poiInfo);
            if (minX > poiInfo->x) minX = poiInfo->x;
            if (minY > poiInfo->y) minY = poiInfo->y;
            if (maxX < poiInfo->x) maxX = poiInfo->x;
            if (maxY < poiInfo->y) maxY = poiInfo->y;
        }
    }
    minX -= 20; minY -= 20; maxX += 20; maxY += 20;

    QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM gameobject,gameobject_template"
        " WHERE gameobject.map=571"
        " AND gameobject.position_x>%f AND gameobject.position_y>%f"
        " AND gameobject.position_x<%f AND gameobject.position_y<%f"
        " AND gameobject_template.type=33"
        " AND gameobject.id=gameobject_template.entry",
        minX, minY, maxX, maxY);
    if (!result)
        return false;

    do
    {
        Field *fields = result->Fetch();

        uint32 guid = fields[0].GetUInt32();
        GameObjectData const * goData = objmgr.GetGOData(guid);
        if (!goData) // this should not happen
            continue;

        float x = goData->posX, y = goData->posY;
        float minDist = 100;
        AreaPOIList::iterator poi = areaPOIs.end();
        for (AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end(); ++itr)
        {
            if (!(*itr)->icon[1]) // note: may for other use
                continue;

            float dist = (abs((*itr)->x - x) + abs((*itr)->y - y));
            if (minDist > dist)
            {
                minDist = dist;
                poi = itr;
            }
        }

        if (poi == areaPOIs.end())
            continue;

        // add building to the list
        TeamId teamId = x > POS_X_CENTER ? m_defender : OTHER_TEAM(m_defender);
        m_buildingStates[guid] = new BuildingState((*poi)->worldState, teamId, m_defender != TEAM_ALLIANCE);
        if ((*poi)->id == 2246)
        {
            m_gate = m_buildingStates[guid];
        }
        areaPOIs.erase(poi);

        // add capture point
        uint32 capturePointEntry = 0;

        switch(goData->id)
        {
            case 192028: capturePointEntry = 190475; break;
            case 192029: capturePointEntry = 190487; break; // not sure
            case 192030: capturePointEntry = 190475; break;
            case 192031: capturePointEntry = 190487; break;
            case 192032: capturePointEntry = 190475; break;
            case 192033: capturePointEntry = 190487; break;
        }
        if (capturePointEntry)
        {
            uint32 engGuid = 0;

            QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature"
                " WHERE creature.map=571"
                " AND creature.id IN (%u, %u);", CRE_ENG_A, CRE_ENG_H);

            if (!result)
            {
                sLog.outError("Cannot find siege workshop master in creature!");
                continue;
            }

            float minDist = 100;
            do
            {
                Field *fields = result->Fetch();
                uint32 guid = fields[0].GetUInt32();
                const CreatureData *creData = objmgr.GetCreatureData(guid);
                if (!creData)
                    continue;

                float dist = (abs(creData->posX - x) + abs(creData->posY - y));
                if (minDist > dist)
                {
                    minDist = dist;
                    engGuid = guid;
                }
            }while(result->NextRow());
            delete result;

            if (!engGuid)
            {
                sLog.outError("Cannot find nearby siege workshop master!");
                continue;
            }

            SiegeWorkshop *workshop = new SiegeWorkshop(this, m_buildingStates[guid]);
            if (!workshop->SetCapturePointData(capturePointEntry, goData->mapid, goData->posX + 40 * cos(goData->orientation + M_PI / 2), goData->posY + 40 * sin(goData->orientation + M_PI / 2), goData->posZ))
            {
                delete workshop;
                sLog.outError("Cannot add capture point!");
                continue;
            }
            const CreatureData *creData = objmgr.GetCreatureData(engGuid);
            if (!creData)
                continue;

            workshop->m_engEntry = const_cast<uint32*>(&creData->id);
            const_cast<CreatureData*>(creData)->displayid = 0;
            workshop->m_workshopGuid = guid;
            workshop->m_engGuid = engGuid;
            //workshop->AddGO(0, guid, goData->id);
            //workshop->AddCre(0, engGuid, creData->id);
            //sLog.outDebug("Demolisher Engineerer lowguid %u is linked to workshop lowguid %u.", engGuid, guid);
            AddCapturePoint(workshop);
            m_buildingStates[guid]->type = BUILDING_WORKSHOP;
            workshop->SetTeamByBuildingState();
        }
    }while(result->NextRow());
    delete result;

    if (!m_gate)
    {
        sLog.outError("Cannot find wintergrasp fortress gate!");
        return false;
    }

    // Load Graveyard
    GraveYardMap::const_iterator graveLow  = objmgr.mGraveYardMap.lower_bound(ZONE_WINTERGRASP);
    GraveYardMap::const_iterator graveUp   = objmgr.mGraveYardMap.upper_bound(ZONE_WINTERGRASP);
    for (AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end();)
    {
        if ((*itr)->icon[1] == 8)
        {
            // find or create grave yard
            const WorldSafeLocsEntry *loc = objmgr.GetClosestGraveYard((*itr)->x, (*itr)->y, (*itr)->z, (*itr)->mapId, 0);
            if (!loc)
            {
                ++itr;
                continue;
            }

            GraveYardMap::const_iterator graveItr;
            for (graveItr = graveLow; graveItr != graveUp; ++graveItr)
                if (graveItr->second.safeLocId == loc->ID)
                    break;
            if (graveItr == graveUp)
            {
                GraveYardData graveData;
                graveData.safeLocId = loc->ID;
                graveData.team = 0;
                graveItr = objmgr.mGraveYardMap.insert(std::make_pair(ZONE_WINTERGRASP, graveData));
            }

            for (BuildingStateMap::iterator stateItr = m_buildingStates.begin(); stateItr != m_buildingStates.end(); ++stateItr)
            {
                if (stateItr->second->worldState == (*itr)->worldState)
                {
                    stateItr->second->graveTeam = const_cast<uint32*>(&graveItr->second.team);
                    break;
                }
            }
            areaPOIs.erase(itr++);
        }
        else
            ++itr;
    }

    //for (AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end(); ++itr)
    //    sLog.outError("not assigned %u %f %f", (*itr)->id, (*itr)->x, (*itr)->y);

    //gameeventmgr.StartInternalEvent(GameEventWintergraspDefender[m_defender]);

    //Titan Relic eventid = 19982
    objmgr.AddGOData(192829, 571, 5440, 2840.8, 420.43 + 10, 0);

    LoadTeamPair(m_goDisplayPair, GODisplayPair);
    LoadTeamPair(m_creEntryPair, CreatureEntryPair);

    m_wartime = false;
    m_timer = sWorld.getConfig(CONFIG_OUTDOORPVP_WINTERGRASP_START_TIME) * MINUTE * IN_MILISECONDS;

    // Load custom rewards
    if (sWorld.getConfig(CONFIG_OUTDOORPVP_WINTERGRASP_CUSTOM_HONOR))
        for (int i = 0; i < WG_REWARD_EVENT_MAX; ++i)
            m_customHonorReward[i] = sWorld.getConfig(CONFIG_OUTDOORPVP_WINTERGRASP_CUSTOM_HONOR_0 + i);

    RemoveOfflinePlayerWGAuras();

    RegisterZone(ZONE_WINTERGRASP);
    return true;
}
Esempio n. 8
0
bool BattlefieldWG::SetupBattlefield()
{
    InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]);

    m_TypeId = BATTLEFIELD_WG;                              // See enum BattlefieldTypes
    m_BattleId = BATTLEFIELD_BATTLEID_WG;
    m_ZoneId = BATTLEFIELD_WG_ZONEID;
    _MapId = BATTLEFIELD_WG_MAPID;

    m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLAYER_MAX);
    m_enable = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE);
    m_MinPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLAYER_MIN);
    m_MinLevel = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLAYER_MIN_LVL);
    m_BattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_BATTLETIME) * MINUTE * IN_MILLISECONDS;
    m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_NOBATTLETIME) * MINUTE * IN_MILLISECONDS;
    m_RestartAfterCrash = sWorld->getIntConfig(CONFIG_WINTERGRASP_RESTART_AFTER_CRASH) * MINUTE * IN_MILLISECONDS;

    m_TimeForAcceptInvite = 20;
    m_StartGroupingTimer = 15 * MINUTE * IN_MILLISECONDS;
    m_StartGrouping = false;

    m_tenacityStack = 0;

    KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
    KickPosition.m_mapId = _MapId;

    RegisterZone(m_ZoneId);

    m_Data32.resize(BATTLEFIELD_WG_DATA_MAX);

    m_saveTimer = 60000;

    // Init GraveYards
    SetGraveyardNumber(BATTLEFIELD_WG_GY_MAX);

    // Load from db
    if ((sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) == 0) && (sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) == 0)
            && (sWorld->getWorldState(ClockWorldState[0]) == 0))
    {
        sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, false);
        sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, urand(0, 1));
        sWorld->setWorldState(ClockWorldState[0], m_NoWarBattleTime);
    }

    m_BattlefieldActive = sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE);
    m_DefenderTeam = TeamId(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER));

    m_Timer = sWorld->getWorldState(ClockWorldState[0]);
    if (m_BattlefieldActive)
    {
        m_BattlefieldActive = false;
        m_Timer = m_RestartAfterCrash;
    }

    for (uint8 i = 0; i < BATTLEFIELD_WG_GY_MAX; i++)
    {
        BfGraveYardWG *gy = new BfGraveYardWG(this);
        if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL) // When between games, the graveyard is controlled by the defending team
            gy->Init(NPC_TAUNKA_SPIRIT_GUIDE, NPC_DWARVEN_SPIRIT_GUIDE, WGGraveYard[i].x, WGGraveYard[i].y, WGGraveYard[i].z, WGGraveYard[i].o, m_DefenderTeam, WGGraveYard[i].gyid);
        else
            gy->Init(NPC_TAUNKA_SPIRIT_GUIDE, NPC_DWARVEN_SPIRIT_GUIDE, WGGraveYard[i].x, WGGraveYard[i].y, WGGraveYard[i].z, WGGraveYard[i].o, WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);
        gy->SetTextId(WGGraveYard[i].textid);
        m_GraveYardList[i] = gy;
    }

    // Spawn workshop creatures and gameobjects
    for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++)
    {
        BfWGWorkShopData *ws = new BfWGWorkShopData(this);      // Create new object
        // Init:setup variable
        ws->Init(WGWorkShopDataBase[i].worldstate, WGWorkShopDataBase[i].type, WGWorkShopDataBase[i].nameid);
        // Spawn associate npc on this point (Guard/Engineer)
        for (uint8 c = 0; c < WGWorkShopDataBase[i].nbcreature; c++)
            ws->AddCreature(WGWorkShopDataBase[i].CreatureData[c]);

        // Spawn associate gameobject on this point (Horde/Alliance flags)
        for (uint8 g = 0; g < WGWorkShopDataBase[i].nbgob; g++)
            ws->AddGameObject(WGWorkShopDataBase[i].GameObjectData[g]);

        // Create PvPCapturePoint
        if (WGWorkShopDataBase[i].type < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST)
        {
            ws->ChangeControl(GetAttackerTeam(), true);     // Update control of this point
            // Create Object
            BfCapturePointWG *workshop = new BfCapturePointWG(this, GetAttackerTeam());
            // Spawn gameobject associate (see in OnGameObjectCreate, of OutdoorPvP for see association)
            workshop->SetCapturePointData(WGWorkShopDataBase[i].CapturePoint.entryh, 571,
                                          WGWorkShopDataBase[i].CapturePoint.x, WGWorkShopDataBase[i].CapturePoint.y, WGWorkShopDataBase[i].CapturePoint.z, 0);
            workshop->LinkToWorkShop(ws);                   // Link our point to the capture point (for faction changement)
            AddCapturePoint(workshop);                      // Add this capture point to list for update this (view in Update() of OutdoorPvP)
        }
        else
            ws->ChangeControl(GetDefenderTeam(), true);     // Update control of this point (Keep workshop= to deffender team)

        WorkShopList.insert(ws);
    }
    // Spawning npc in keep
    for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++)
    {
        // Horde npc
        if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryh, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE))
            KeepCreature[TEAM_HORDE].insert(creature->GetGUID());
        // Alliance npc
        if (Creature* creature = SpawnCreature(WGKeepNPC[i].entrya, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE))
            KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
    }
    // Hide keep npc
    for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
        if (Unit* unit = ObjectAccessor::FindUnit(*itr))
            if (Creature* creature = unit->ToCreature())
                HideNpc(creature);
    // Spawn out of keep npc
    // Horde npc
    for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++)
        if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryh, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE))
            OutsideCreature[TEAM_HORDE].insert(creature->GetGUID());
    // Alliance npc
    for (uint8 i = WG_OUTSIDE_ALLIANCE_NPC; i < WG_MAX_OUTSIDE_NPC; i++)
        if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entrya, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE))
            OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
    // Hide outside npc
    for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
        if (Unit* unit = ObjectAccessor::FindUnit(*itr))
            if (Creature* creature = unit->ToCreature())
                HideNpc(creature);
    for (uint8 i = 0; i < WG_MAX_TURRET; i++)
    {
        if (Creature* creature = SpawnCreature(28366, WGTurret[i].x, WGTurret[i].y, WGTurret[i].z, WGTurret[i].o, TeamId(0)))
        {
            CanonList.insert(creature->GetGUID());
            HideNpc(creature);
        }
    }
    // Spawning Buiding
    for (uint8 i = 0; i < WG_MAX_OBJ; i++)
    {
        GameObject* go =
            SpawnGameObject(WGGameObjectBuillding[i].entry, WGGameObjectBuillding[i].x, WGGameObjectBuillding[i].y, WGGameObjectBuillding[i].z, WGGameObjectBuillding[i].o);
        BfWGGameObjectBuilding *b = new BfWGGameObjectBuilding(this);
        b->Init(go, WGGameObjectBuillding[i].type, WGGameObjectBuillding[i].WorldState, WGGameObjectBuillding[i].nameid);
        BuildingsInZone.insert(b);
    }
    // Spawning portal defender
    for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++)
    {
        GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o);
        DefenderPortalList.insert(go);
        go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]);
    }

    // Spawn banner in keep
    for (uint8 i = 0; i < WG_KEEPGAMEOBJECT_MAX; i++)
    {
        if (GameObject* go = SpawnGameObject(WGKeepGameObject[i].entryh, WGKeepGameObject[i].x, WGKeepGameObject[i].y, WGKeepGameObject[i].z, WGKeepGameObject[i].o))
        {
            go->SetRespawnTime(GetDefenderTeam()? RESPAWN_ONE_DAY : RESPAWN_IMMEDIATELY);
            m_KeepGameObject[1].insert(go);
        }
        if (GameObject* go = SpawnGameObject(WGKeepGameObject[i].entrya, WGKeepGameObject[i].x, WGKeepGameObject[i].y, WGKeepGameObject[i].z, WGKeepGameObject[i].o))
        {
            go->SetRespawnTime(GetDefenderTeam()? RESPAWN_IMMEDIATELY : RESPAWN_ONE_DAY);
            m_KeepGameObject[0].insert(go);
        }
    }

    // Show defender banner in keep
    for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr)
        (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY);

    // Hide attackant banner in keep
    for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetAttackerTeam()].begin(); itr != m_KeepGameObject[GetAttackerTeam()].end(); ++itr)
        (*itr)->SetRespawnTime(RESPAWN_ONE_DAY);

    UpdateCounterVehicle(true);
    return true;
}
void WintergraspWorkshopData::UpdateGraveyard()
{
    // East Fortress Workshops - no own graveyard
    if (m_workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_EAST)
        m_WG->GetGraveyardById(m_workshopId)->GiveControlTo(TeamId(m_TeamControl));
}
void WintergraspWorkshopData::GiveControlTo(uint8 team)
{
    // Find associate graveyard and update it
    if (m_workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_EAST)
        if (m_WG->GetGraveyardById(m_workshopId))
            m_WG->GetGraveyardById(m_workshopId)->GiveControlTo(TeamId(team));

    if (team != TEAM_NEUTRAL)
    {
        // Hide current creatures
        for (GuidSet::const_iterator itr = m_CreatureOnPoint[m_WG->GetOtherTeam(TeamId(team))].begin(); itr != m_CreatureOnPoint[m_WG->GetOtherTeam(TeamId(team))].end(); ++itr)
            if (Creature* pCreature = m_WG->GetCreature(*itr))
                m_WG->HideNpc(pCreature);

        // Show controller creatures
        for (GuidSet::const_iterator itr = m_CreatureOnPoint[TeamId(team)].begin(); itr != m_CreatureOnPoint[TeamId(team)].end(); ++itr)
        {
            if (Creature* pCreature = m_WG->GetCreature(*itr))
            {
                m_WG->ShowNpc(pCreature, (pCreature->GetEntry() != BATTLEFIELD_WG_NPC_GNOMISH_MECHANIC_ENGINEER
                    && pCreature->GetEntry() != BATTLEFIELD_WG_NPC_GOBLIN_MECHANIC_ENGINEER));
                pCreature->SetPosition(pCreature->GetHomePosition());
            }
        }

        // Hide current gameobjects
        for (GuidSet::const_iterator itr = m_GameObjectOnPoint[m_WG->GetOtherTeam(TeamId(team))].begin(); itr != m_GameObjectOnPoint[m_WG->GetOtherTeam(TeamId(team))].end(); ++itr)
            if (GameObject* object = m_WG->GetGameObject(*itr))
                object->SetRespawnTime(RESPAWN_ONE_DAY);

        // Show controller gameobjects
        for (GuidSet::const_iterator itr = m_GameObjectOnPoint[TeamId(team)].begin(); itr != m_GameObjectOnPoint[TeamId(team)].end(); ++itr)
            if (GameObject* object = m_WG->GetGameObject(*itr))
                object->SetRespawnTime(RESPAWN_IMMEDIATELY);
    }

    switch (team)
    {
        case BATTLEFIELD_WG_TEAM_NEUTRAL:
        {
            // Send warning message to all player for inform a faction attack a workshop
            // alliance / horde attacking workshop
            m_WG->SendWarningToAllInZone(m_TeamControl ? LANG_WG_WORKSHOP_ATTACK_ALLIANCE : LANG_WG_WORKSHOP_ATTACK_HORDE, m_NameId);

            // Updating worldstate
            m_State = BATTLEFIELD_WG_OBJECTSTATE_NEUTRAL_INTACT;
            m_WG->SendUpdateWorldState(m_WorldState, m_State);

            // Hide current Engineer
            if (Creature* pEngineer = m_WG->GetCreature(m_Engineer[m_TeamControl]))
                m_WG->HideNpc(pEngineer);

            // Update GameObject ArtKit of the Factory Banner (only outside workshops)
            if (m_FactoryGUID != 0 && m_WG->IsWarTime())
            {
                GameObject* pFactory = m_WG->GetGameObject(m_FactoryGUID);
                if (pFactory)
                    GameObject::SetGoArtKit(GO_ARTKIT_FACTORY_NEUTRAL, pFactory, pFactory->GetGUIDLow());
            }
        }break;

        case BATTLEFIELD_WG_TEAM_ALLIANCE:
        {
            // Hide Horde Engineer - has to be done at init
            if (Creature* pEngineer = m_WG->GetCreature(m_Engineer[TEAM_HORDE]))
                m_WG->HideNpc(pEngineer);

            // Show Alliance Engineer - If it isn't wartime, hide engineer per default
            if (Creature* pEngineer = m_WG->GetCreature(m_Engineer[TEAM_ALLIANCE]))
            {
                if (m_WG->IsWarTime())
                    m_WG->ShowNpc(pEngineer, false);
                else
                    m_WG->HideNpc(pEngineer);
            }

            // Updating worldstate
            m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_INTACT;
            m_WG->SendUpdateWorldState(m_WorldState, m_State);

            // Warning message
            if (m_WG->IsWarTime() && m_workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST) // workshop taken - alliance
                m_WG->SendWarningToAllInZone(LANG_WG_WORKSHOP_TAKEN_ALLIANCE, m_NameId);

            // Update GameObject ArtKit of the Factory Banner (only outside workshops)
            if (m_FactoryGUID != 0 && m_WG->IsWarTime())
            {
                GameObject* pFactory = m_WG->GetGameObject(m_FactoryGUID);
                if (pFactory)
                    GameObject::SetGoArtKit(GO_ARTKIT_FACTORY_ALLIANCE, pFactory, pFactory->GetGUIDLow());
            }
        }break;

        case BATTLEFIELD_WG_TEAM_HORDE:
        {
            // Hide Alliance Engineer - has to be done at init
            if (Creature* pEngineer = m_WG->GetCreature(m_Engineer[TEAM_ALLIANCE]))
                m_WG->HideNpc(pEngineer);

            // Show Horde Engineer - If it isn't wartime, hide engineer per default
            if (Creature* pEngineer = m_WG->GetCreature(m_Engineer[TEAM_HORDE]))
            {
                if (m_WG->IsWarTime())
                    m_WG->ShowNpc(pEngineer, false);
                else
                    m_WG->HideNpc(pEngineer);
            }

            // Update worldstate
            m_State = BATTLEFIELD_WG_OBJECTSTATE_HORDE_INTACT;
            m_WG->SendUpdateWorldState(m_WorldState, m_State);

            // Warning message
            if (m_WG->IsWarTime() && m_workshopId < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST) // workshop taken - horde
                m_WG->SendWarningToAllInZone(LANG_WG_WORKSHOP_TAKEN_HORDE, m_NameId);

            // Update GameObject ArtKit of the Factory Banner (only outside workshops)
            if (m_FactoryGUID != 0 && m_WG->IsWarTime())
            {
                GameObject* pFactory = m_WG->GetGameObject(m_FactoryGUID);
                if (pFactory)
                    GameObject::SetGoArtKit(GO_ARTKIT_FACTORY_HORDE, pFactory, pFactory->GetGUIDLow());
            }
        }break;
    }

    m_TeamControl = team;

    if (!m_RocketLauncherOnPoint.empty())
        for (GuidSet::const_iterator itr = m_RocketLauncherOnPoint.begin(); itr != m_RocketLauncherOnPoint.end(); ++itr)
            if (Creature* pCreature = m_WG->GetCreature(*itr))
                pCreature->setFaction(WintergraspFaction[team]);

    if (m_WG->IsWarTime())
        m_WG->UpdateCounterVehicle(false);
}