*Format BattleGroundSA.cpp
*Check if game is still in progress before awarding teams *Resurrect and refresh players at round end --HG-- branch : trunk
This commit is contained in:
+25
-36
@@ -38,7 +38,6 @@ BattleGroundSA::BattleGroundSA()
|
||||
|
||||
BattleGroundSA::~BattleGroundSA()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::Reset()
|
||||
@@ -46,22 +45,18 @@ void BattleGroundSA::Reset()
|
||||
TotalTime = 0;
|
||||
attackers = ( (urand(0,1)) ? TEAM_ALLIANCE : TEAM_HORDE);
|
||||
for(uint8 i = 0; i <= 5; i++)
|
||||
{
|
||||
GateStatus[i] = BG_SA_GATE_OK;
|
||||
}
|
||||
ShipsStarted = false;
|
||||
status = BG_SA_WARMUP;
|
||||
}
|
||||
|
||||
bool BattleGroundSA::SetupBattleGround()
|
||||
{
|
||||
|
||||
return ResetObjs();
|
||||
}
|
||||
|
||||
bool BattleGroundSA::ResetObjs()
|
||||
{
|
||||
|
||||
uint32 atF = BG_SA_Factions[attackers];
|
||||
uint32 defF = BG_SA_Factions[attackers ? TEAM_ALLIANCE : TEAM_HORDE];
|
||||
|
||||
@@ -85,7 +80,6 @@ bool BattleGroundSA::ResetObjs()
|
||||
BG_SA_ObjSpawnlocs[i][2],BG_SA_ObjSpawnlocs[i][3],
|
||||
0,0,0,0,RESPAWN_ONE_DAY))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
GetBGObject(BG_SA_TITAN_RELIC)->SetUInt32Value(GAMEOBJECT_FACTION, defF);
|
||||
@@ -110,9 +104,7 @@ bool BattleGroundSA::ResetObjs()
|
||||
}
|
||||
|
||||
for(uint8 i = 0; i <= 5; i++)
|
||||
{
|
||||
GateStatus[i] = BG_SA_GATE_OK;
|
||||
}
|
||||
|
||||
// MAD props for Kiper for discovering those values - 4 hours of his work.
|
||||
GetBGObject(BG_SA_BOAT_ONE)->UpdateRotationFields(1.0f, 0.0002f);
|
||||
@@ -144,11 +136,9 @@ bool BattleGroundSA::ResetObjs()
|
||||
{
|
||||
GraveyardStatus[i] = ((attackers == TEAM_HORDE )? TEAM_ALLIANCE : TEAM_HORDE);
|
||||
if(!AddSpiritGuide(i + BG_SA_MAXNPC, sg->x, sg->y, sg->z, BG_SA_GYOrientation[i], ((attackers == TEAM_HORDE )? ALLIANCE : HORDE) ))
|
||||
{
|
||||
sLog.outError("SOTA: couldn't spawn GY: %u",i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//GY capture points
|
||||
for(uint8 i = BG_SA_CENTRAL_FLAG; i < BG_SA_MAXOBJ; i++)
|
||||
@@ -181,7 +171,6 @@ bool BattleGroundSA::ResetObjs()
|
||||
|
||||
UpdateWorldState(BG_SA_HORDE_DEFENCE_TOKEN,1);
|
||||
UpdateWorldState(BG_SA_ALLIANCE_DEFENCE_TOKEN,0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -195,7 +184,6 @@ bool BattleGroundSA::ResetObjs()
|
||||
|
||||
UpdateWorldState(BG_SA_HORDE_DEFENCE_TOKEN,0);
|
||||
UpdateWorldState(BG_SA_ALLIANCE_DEFENCE_TOKEN,1);
|
||||
|
||||
}
|
||||
|
||||
UpdateWorldState(BG_SA_PURPLE_GATEWS, 1);
|
||||
@@ -206,7 +194,6 @@ bool BattleGroundSA::ResetObjs()
|
||||
UpdateWorldState(BG_SA_ANCIENT_GATEWS, 1);
|
||||
|
||||
TeleportPlayers();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -214,6 +201,7 @@ void BattleGroundSA::StartShips()
|
||||
{
|
||||
if(ShipsStarted)
|
||||
return;
|
||||
|
||||
DoorOpen(BG_SA_BOAT_ONE);
|
||||
DoorOpen(BG_SA_BOAT_TWO);
|
||||
|
||||
@@ -234,7 +222,6 @@ void BattleGroundSA::StartShips()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShipsStarted = true;
|
||||
}
|
||||
|
||||
@@ -253,10 +240,11 @@ void BattleGroundSA::Update(uint32 diff)
|
||||
}
|
||||
if(TotalTime >= BG_SA_BOAT_START)
|
||||
StartShips();
|
||||
|
||||
return;
|
||||
}
|
||||
else if(status == BG_SA_ROUND_ONE)
|
||||
else if (GetStatus() == STATUS_IN_PROGRESS)
|
||||
{
|
||||
if(status == BG_SA_ROUND_ONE)
|
||||
{
|
||||
if(TotalTime >= BG_SA_ROUNDLENGTH)
|
||||
{
|
||||
@@ -284,14 +272,13 @@ void BattleGroundSA::Update(uint32 diff)
|
||||
EndBattleGround(RoundScores[0].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE);
|
||||
else
|
||||
EndBattleGround(RoundScores[1].winner == TEAM_ALLIANCE ? ALLIANCE : HORDE);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(status == BG_SA_ROUND_ONE || status == BG_SA_ROUND_TWO)
|
||||
SendTime();
|
||||
}
|
||||
}
|
||||
|
||||
void BattleGroundSA::StartingEventCloseDoors()
|
||||
{
|
||||
@@ -348,6 +335,7 @@ void BattleGroundSA::AddPlayer(Player *plr)
|
||||
BattleGroundSAScore* sc = new BattleGroundSAScore;
|
||||
|
||||
if(!ShipsStarted)
|
||||
{
|
||||
if(plr->GetTeamId() == attackers)
|
||||
{
|
||||
plr->CastSpell(plr,12438,true);//Without this player falls before boat loads...
|
||||
@@ -357,8 +345,10 @@ void BattleGroundSA::AddPlayer(Player *plr)
|
||||
else
|
||||
plr->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0);
|
||||
|
||||
}else
|
||||
}
|
||||
else
|
||||
plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(plr->GetTeamId() == attackers)
|
||||
@@ -372,7 +362,6 @@ void BattleGroundSA::AddPlayer(Player *plr)
|
||||
|
||||
void BattleGroundSA::RemovePlayer(Player* /*plr*/,uint64 /*guid*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/)
|
||||
@@ -384,7 +373,6 @@ void BattleGroundSA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/)
|
||||
|
||||
void BattleGroundSA::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
|
||||
{
|
||||
|
||||
BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID());
|
||||
if(itr == m_PlayerScores.end()) // player not found...
|
||||
return;
|
||||
@@ -403,6 +391,19 @@ void BattleGroundSA::TeleportPlayers()
|
||||
{
|
||||
if(Player *plr = objmgr.GetPlayer(itr->first))
|
||||
{
|
||||
// should remove spirit of redemption
|
||||
if(plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
|
||||
|
||||
if (!plr->isAlive())
|
||||
{
|
||||
plr->ResurrectPlayer(1.0f);
|
||||
plr->SpawnCorpseBones();
|
||||
}
|
||||
|
||||
plr->SetHealth(plr->GetMaxHealth());
|
||||
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
|
||||
plr->CombatStopWithPets(true);
|
||||
|
||||
if(plr->GetTeamId() == attackers)
|
||||
{
|
||||
@@ -415,14 +416,12 @@ void BattleGroundSA::TeleportPlayers()
|
||||
}
|
||||
else
|
||||
plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BattleGroundSA::EventPlayerDamagedGO(Player* plr, GameObject* go, uint32 event)
|
||||
{
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case 19046: //Green gate destroyed
|
||||
@@ -446,7 +445,6 @@ void BattleGroundSA::EventPlayerDamagedGO(Player* plr, GameObject* go, uint32 ev
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::HandleKillUnit(Creature* unit, Player* killer)
|
||||
@@ -456,7 +454,6 @@ void BattleGroundSA::HandleKillUnit(Creature* unit, Player* killer)
|
||||
|
||||
if(unit->GetEntry() == 28781) //Demolisher
|
||||
UpdatePlayerScore(killer, SCORE_DESTROYED_DEMOLISHER, 1);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -469,17 +466,16 @@ void BattleGroundSA::OverrideGunFaction()
|
||||
return;
|
||||
|
||||
for(uint8 i = BG_SA_GUN_1; i <= BG_SA_GUN_10;i++)
|
||||
if(Creature* gun = GetBGCreature(i))
|
||||
{
|
||||
if(Creature* gun = GetBGCreature(i))
|
||||
gun->setFaction(BG_SA_Factions[attackers? TEAM_ALLIANCE : TEAM_HORDE]);
|
||||
}
|
||||
|
||||
for(uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_4;i++)
|
||||
if(Creature* dem = GetBGCreature(i))
|
||||
{
|
||||
if(Creature* dem = GetBGCreature(i))
|
||||
dem->setFaction(BG_SA_Factions[attackers]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::DestroyGate(uint32 i, Player* pl)
|
||||
@@ -524,7 +520,6 @@ void BattleGroundSA::DestroyGate(uint32 i, Player* pl)
|
||||
UpdatePlayerScore(pl,SCORE_DESTROYED_WALL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WorldSafeLocsEntry const* BattleGroundSA::GetClosestGraveYard(Player* player)
|
||||
@@ -570,7 +565,6 @@ void BattleGroundSA::SendTime()
|
||||
|
||||
void BattleGroundSA::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj)
|
||||
{
|
||||
|
||||
switch(target_obj->GetEntry())
|
||||
{
|
||||
case 191307:
|
||||
@@ -588,12 +582,10 @@ void BattleGroundSA::EventPlayerClickedOnFlag(Player *Source, GameObject* target
|
||||
default:
|
||||
return;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::CaptureGraveyard(BG_SA_Graveyards i)
|
||||
{
|
||||
|
||||
DelCreature(BG_SA_MAXNPC + i);
|
||||
GraveyardStatus[i] = (GraveyardStatus[i] == TEAM_ALLIANCE? TEAM_HORDE : TEAM_ALLIANCE);
|
||||
WorldSafeLocsEntry const *sg = NULL;
|
||||
@@ -630,8 +622,6 @@ void BattleGroundSA::CaptureGraveyard(BG_SA_Graveyards i)
|
||||
ASSERT(0);
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::EventPlayerUsedGO(Player* Source, GameObject* object)
|
||||
@@ -667,10 +657,8 @@ void BattleGroundSA::EventPlayerUsedGO(Player* Source, GameObject* object)
|
||||
|
||||
void BattleGroundSA::ToggleTimer()
|
||||
{
|
||||
|
||||
TimerEnabled = !TimerEnabled;
|
||||
UpdateWorldState(BG_SA_ENABLE_TIMER, (TimerEnabled) ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
void BattleGroundSA::EndBattleGround(uint32 winner)
|
||||
@@ -688,3 +676,4 @@ void BattleGroundSA::EndBattleGround(uint32 winner)
|
||||
BattleGround::EndBattleGround(winner);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user