aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoschiwald <joschiwald.trinity@gmail.com>2015-05-21 13:36:28 +0200
committerjoschiwald <joschiwald.trinity@gmail.com>2015-05-21 13:36:28 +0200
commit8afa15ef15b3d540208e89dd8e9072bd75af041d (patch)
tree06200e13c74c25209c37b9d2553f98360e4d2f66 /src
parent654332e94b0ef746309251b77f5658f5b6a03c62 (diff)
Core/BG/SOA: fixed interaction with flags and titan relic
Closes #13091
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp122
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundSA.h6
2 files changed, 81 insertions, 47 deletions
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
index e14e9fadafc..f267bf7c6c6 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
@@ -99,7 +99,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]))
@@ -179,9 +179,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;
@@ -221,6 +218,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))
@@ -481,28 +480,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*/) { }
@@ -533,23 +511,31 @@ 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);
+ TeleportToEntrancePosition(player);
+ }
+ }
+}
- 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);
- }
+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, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
+ 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*/)
@@ -628,6 +614,8 @@ void BattlegroundSA::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject*
}
}
}
+
+ UpdateObjectInteractionFlags();
}
else
break;
@@ -711,7 +699,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
safeloc = BG_SA_GYEntries[BG_SA_DEFENDER_LAST_GY];
closest = sWorldSafeLocsStore.LookupEntry(safeloc);
- nearest = std::sqrt((closest->x - x)*(closest->x - x) + (closest->y - y)*(closest->y - y) + (closest->z - z)*(closest->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++)
{
@@ -719,7 +707,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player)
continue;
ret = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
- dist = std::sqrt((ret->x - x)*(ret->x - x) + (ret->y - y)*(ret->y - y) + (ret->z - z)*(ret->z - z));
+ dist = player->GetExactDistSq(ret->x, ret->y, ret->z);
if (dist < nearest)
{
closest = ret;
@@ -738,23 +726,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:
@@ -856,10 +887,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)
{
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
index 7f9a656c979..118cea41a7b 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
@@ -620,6 +620,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
@@ -627,6 +628,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