Core/BG/SOA: fixed interaction with flags and titan relic

Closes #13091

(cherry picked from commit 8afa15ef15)

Conflicts:
	src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
This commit is contained in:
joschiwald
2015-05-21 13:36:28 +02:00
committed by DDuarte
parent fd1b69eb3f
commit 80bc699874
3 changed files with 84 additions and 49 deletions

View File

@@ -0,0 +1 @@
UPDATE `gameobject_template` SET `flags`=48 WHERE `entry`=191306;

View File

@@ -100,7 +100,7 @@ bool BattlegroundSA::ResetObjs()
for (uint8 i = BG_SA_MAXNPC; i < BG_SA_MAXNPC + BG_SA_MAX_GY; i++)
DelCreature(i);
for (uint8 i = 0; i < 6; i++)
for (uint8 i = 0; i < MAX_GATES; ++i)
GateStatus[i] = BG_SA_GATE_OK;
if (!AddCreature(BG_SA_NpcEntries[BG_SA_NPC_KANRETHAD], BG_SA_NPC_KANRETHAD, BG_SA_NpcSpawnlocs[BG_SA_NPC_KANRETHAD]))
@@ -180,9 +180,6 @@ bool BattlegroundSA::ResetObjs()
GetBGObject(BG_SA_TITAN_RELIC)->SetFaction(atF);
GetBGObject(BG_SA_TITAN_RELIC)->Refresh();
for (uint8 i = 0; i <= 5; i++)
GateStatus[i] = BG_SA_GATE_OK;
TotalTime = 0;
ShipsStarted = false;
@@ -222,6 +219,8 @@ bool BattlegroundSA::ResetObjs()
GetBGObject(i)->SetFaction(atF);
}
UpdateObjectInteractionFlags();
for (uint8 i = BG_SA_BOMB; i < BG_SA_MAXOBJ; i++)
{
if (!AddObject(i, BG_SA_ObjEntries[BG_SA_BOMB], BG_SA_ObjSpawnlocs[i], 0, 0, 0, 0, RESPAWN_ONE_DAY))
@@ -482,28 +481,7 @@ void BattlegroundSA::AddPlayer(Player* player)
SendTransportInit(player);
if (!ShipsStarted)
{
if (player->GetTeamId() == Attackers)
{
//player->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
if (urand(0, 1))
player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
else
player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
}
else
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
}
else
{
if (player->GetTeamId() == Attackers)
player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
else
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
}
TeleportToEntrancePosition(player);
}
void BattlegroundSA::RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/) { }
@@ -534,25 +512,33 @@ void BattlegroundSA::TeleportPlayers()
player->ResetAllPowers();
player->CombatStopWithPets(true);
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
if (Player* p = ObjectAccessor::FindPlayer(itr->first))
p->CastSpell(p, SPELL_PREPARATION, true);
player->CastSpell(player, SPELL_PREPARATION, true);
if (player->GetTeamId() == Attackers)
{
//player->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
if (urand(0, 1))
player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
else
player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
}
else
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
TeleportToEntrancePosition(player);
}
}
}
void BattlegroundSA::TeleportToEntrancePosition(Player* player)
{
if (player->GetTeamId() == Attackers)
{
if (!ShipsStarted)
{
player->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
if (urand(0, 1))
player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
else
player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
}
else
player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
}
else
player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
}
void BattlegroundSA::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject* invoker /*= NULL*/)
{
if (GameObject* go = obj->ToGameObject())
@@ -629,6 +615,8 @@ void BattlegroundSA::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject*
}
}
}
UpdateObjectInteractionFlags();
}
else
break;
@@ -712,7 +700,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
safeloc = BG_SA_GYEntries[BG_SA_DEFENDER_LAST_GY];
closest = sWorldSafeLocsStore.LookupEntry(safeloc);
nearest = std::sqrt((closest->Loc.X - x)*(closest->Loc.X - x) + (closest->Loc.Y - y)*(closest->Loc.Y - y) + (closest->Loc.Z - z)*(closest->Loc.Z - z));
nearest = player->GetExactDistSq(closest->x, closest->y, closest->z);
for (uint8 i = BG_SA_RIGHT_CAPTURABLE_GY; i < BG_SA_MAX_GY; i++)
{
@@ -720,7 +708,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
continue;
ret = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
dist = std::sqrt((ret->Loc.X - x)*(ret->Loc.X - x) + (ret->Loc.Y - y)*(ret->Loc.Y - y) + (ret->Loc.Z - z)*(ret->Loc.Z - z));
dist = player->GetExactDistSq(ret->x, ret->y, ret->z);
if (dist < nearest)
{
closest = ret;
@@ -739,23 +727,66 @@ void BattlegroundSA::SendTime()
UpdateWorldState(BG_SA_TIMER_SEC_DECS, ((end_of_round%60000)%10000)/1000);
}
bool BattlegroundSA::CanInteractWithObject(uint32 objectId)
{
switch (objectId)
{
case BG_SA_TITAN_RELIC:
if (GateStatus[BG_SA_ANCIENT_GATE] != BG_SA_GATE_DESTROYED || GateStatus[BG_SA_YELLOW_GATE] != BG_SA_GATE_DESTROYED)
return false;
// no break
case BG_SA_CENTRAL_FLAG:
if (GateStatus[BG_SA_RED_GATE] != BG_SA_GATE_DESTROYED && GateStatus[BG_SA_PURPLE_GATE] != BG_SA_GATE_DESTROYED)
return false;
// no break
case BG_SA_LEFT_FLAG:
case BG_SA_RIGHT_FLAG:
if (GateStatus[BG_SA_GREEN_GATE] != BG_SA_GATE_DESTROYED && GateStatus[BG_SA_BLUE_GATE] != BG_SA_GATE_DESTROYED)
return false;
break;
default:
ASSERT(false);
break;
}
return true;
}
void BattlegroundSA::UpdateObjectInteractionFlags(uint32 objectId)
{
if (GameObject* go = GetBGObject(objectId))
{
if (CanInteractWithObject(objectId))
go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
else
go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
}
}
void BattlegroundSA::UpdateObjectInteractionFlags()
{
for (uint8 i = BG_SA_CENTRAL_FLAG; i <= BG_SA_LEFT_FLAG; ++i)
UpdateObjectInteractionFlags(i);
UpdateObjectInteractionFlags(BG_SA_TITAN_RELIC);
}
void BattlegroundSA::EventPlayerClickedOnFlag(Player* source, GameObject* go)
{
switch (go->GetEntry())
{
case 191307:
case 191308:
if (GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED)
if (CanInteractWithObject(BG_SA_LEFT_FLAG))
CaptureGraveyard(BG_SA_LEFT_CAPTURABLE_GY, source);
break;
case 191305:
case 191306:
if (GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED)
if (CanInteractWithObject(BG_SA_RIGHT_FLAG))
CaptureGraveyard(BG_SA_RIGHT_CAPTURABLE_GY, source);
break;
case 191310:
case 191309:
if ((GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED) && (GateStatus[BG_SA_RED_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_PURPLE_GATE] == BG_SA_GATE_DESTROYED))
if (CanInteractWithObject(BG_SA_CENTRAL_FLAG))
CaptureGraveyard(BG_SA_CENTRAL_CAPTURABLE_GY, source);
break;
default:
@@ -857,10 +888,7 @@ void BattlegroundSA::TitanRelicActivated(Player* clicker)
if (!clicker)
return;
if (GateStatus[BG_SA_ANCIENT_GATE] == BG_SA_GATE_DESTROYED &&
GateStatus[BG_SA_YELLOW_GATE] == BG_SA_GATE_DESTROYED &&
(GateStatus[BG_SA_PURPLE_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_RED_GATE] == BG_SA_GATE_DESTROYED) &&
(GateStatus[BG_SA_GREEN_GATE] == BG_SA_GATE_DESTROYED || GateStatus[BG_SA_BLUE_GATE] == BG_SA_GATE_DESTROYED))
if (CanInteractWithObject(BG_SA_TITAN_RELIC))
{
if (clicker->GetTeamId() == Attackers)
{

View File

@@ -619,6 +619,7 @@ class BattlegroundSA : public Battleground
* -Teleport all players to good location
*/
void TeleportPlayers();
void TeleportToEntrancePosition(Player* player);
/**
* \brief Called on start and between the two round
* -Update faction of all vehicle
@@ -626,6 +627,11 @@ class BattlegroundSA : public Battleground
void OverrideGunFaction();
/// Set selectable or not demolisher, called on battle start, when boats arrive to dock
void DemolisherStartState(bool start);
/// Checks if a player can interact with the given object
bool CanInteractWithObject(uint32 objectId);
/// Updates interaction flags of specific objects
void UpdateObjectInteractionFlags(uint32 objectId);
void UpdateObjectInteractionFlags();
/**
* \brief Called when a gate is destroy
* -Give honor to player witch destroy it