2010-10-07 15:35:36 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
|
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
|
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
#include "Battleground.h"
|
|
|
|
|
#include "BattlegroundRL.h"
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "Language.h"
|
2009-06-04 21:41:07 +02:00
|
|
|
#include "Object.h"
|
|
|
|
|
#include "ObjectMgr.h"
|
|
|
|
|
#include "Player.h"
|
2009-02-09 22:08:06 -06:00
|
|
|
#include "WorldPacket.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
BattlegroundRL::BattlegroundRL()
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
m_BgObjects.resize(BG_RL_OBJECT_MAX);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-03-07 12:05:30 -06:00
|
|
|
m_StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M;
|
|
|
|
|
m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
|
|
|
|
|
m_StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S;
|
|
|
|
|
m_StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE;
|
|
|
|
|
//we must set messageIds
|
|
|
|
|
m_StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_ARENA_ONE_MINUTE;
|
|
|
|
|
m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_ARENA_THIRTY_SECONDS;
|
|
|
|
|
m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_ARENA_FIFTEEN_SECONDS;
|
|
|
|
|
m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
BattlegroundRL::~BattlegroundRL()
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::Update(uint32 diff)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2010-08-08 04:37:24 +02:00
|
|
|
Battleground::Update(diff);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-12-02 22:25:32 +01:00
|
|
|
if (GetStatus() == STATUS_IN_PROGRESS)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2010-12-02 22:25:32 +01:00
|
|
|
if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change
|
|
|
|
|
{
|
|
|
|
|
UpdateArenaWorldState();
|
|
|
|
|
CheckArenaAfterTimerConditions();
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::StartingEventCloseDoors()
|
2009-03-07 12:05:30 -06:00
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 i = BG_RL_OBJECT_DOOR_1; i <= BG_RL_OBJECT_DOOR_2; ++i)
|
2009-03-07 12:05:30 -06:00
|
|
|
SpawnBGObject(i, RESPAWN_IMMEDIATELY);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::StartingEventOpenDoors()
|
2009-03-07 12:05:30 -06:00
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 i = BG_RL_OBJECT_DOOR_1; i <= BG_RL_OBJECT_DOOR_2; ++i)
|
2009-03-07 12:05:30 -06:00
|
|
|
DoorOpen(i);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 i = BG_RL_OBJECT_BUFF_1; i <= BG_RL_OBJECT_BUFF_2; ++i)
|
2009-03-07 12:05:30 -06:00
|
|
|
SpawnBGObject(i, 60);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::AddPlayer(Player *plr)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2010-08-08 04:37:24 +02:00
|
|
|
Battleground::AddPlayer(plr);
|
2008-10-02 16:23:55 -05:00
|
|
|
//create score and add it to map, default values are set in constructor
|
2010-08-08 04:37:24 +02:00
|
|
|
BattlegroundRLScore* sc = new BattlegroundRLScore;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
m_PlayerScores[plr->GetGUID()] = sc;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-12-17 14:06:20 +01:00
|
|
|
UpdateArenaWorldState();
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::RemovePlayer(Player* /*plr*/, uint64 /*guid*/)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-04-08 16:33:46 -05:00
|
|
|
if (GetStatus() == STATUS_WAIT_LEAVE)
|
2008-10-05 08:48:32 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-12-17 14:06:20 +01:00
|
|
|
UpdateArenaWorldState();
|
2009-03-09 16:36:58 -06:00
|
|
|
CheckArenaWinConditions();
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::HandleKillPlayer(Player *player, Player *killer)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-04-08 16:33:46 -05:00
|
|
|
if (GetStatus() != STATUS_IN_PROGRESS)
|
2008-10-02 16:23:55 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-04-08 16:33:46 -05:00
|
|
|
if (!killer)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
sLog.outError("Killer player not found");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
Battleground::HandleKillPlayer(player,killer);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-12-17 14:06:20 +01:00
|
|
|
UpdateArenaWorldState();
|
2009-03-09 16:36:58 -06:00
|
|
|
CheckArenaWinConditions();
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
bool BattlegroundRL::HandlePlayerUnderMap(Player *player)
|
2008-10-05 08:48:32 -05:00
|
|
|
{
|
2010-08-22 23:46:40 +06:00
|
|
|
player->TeleportTo(GetMapId(),1285.810547f,1667.896851f,39.957642f,player->GetOrientation(),false);
|
2008-10-05 08:48:32 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
// this is wrong way to implement these things. On official it done by gameobject spell cast.
|
2009-04-08 16:33:46 -05:00
|
|
|
if (GetStatus() != STATUS_IN_PROGRESS)
|
2008-10-02 16:23:55 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
//uint32 SpellId = 0;
|
|
|
|
|
//uint64 buff_guid = 0;
|
|
|
|
|
switch(Trigger)
|
|
|
|
|
{
|
|
|
|
|
case 4696: // buff trigger?
|
|
|
|
|
case 4697: // buff trigger?
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
|
|
|
|
|
Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-04-08 16:33:46 -05:00
|
|
|
//if (buff_guid)
|
2008-10-02 16:23:55 -05:00
|
|
|
// HandleTriggerBuff(buff_guid,Source);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::FillInitialWorldStates(WorldPacket &data)
|
2008-10-05 08:48:32 -05:00
|
|
|
{
|
2009-12-17 14:06:20 +01:00
|
|
|
data << uint32(0xbba) << uint32(1); // 9
|
|
|
|
|
UpdateArenaWorldState();
|
2008-10-05 08:48:32 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
void BattlegroundRL::Reset()
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-02-13 20:10:14 -06:00
|
|
|
//call parent's reset
|
2010-08-08 04:37:24 +02:00
|
|
|
Battleground::Reset();
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-08 04:37:24 +02:00
|
|
|
bool BattlegroundRL::SetupBattleground()
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
// gates
|
2010-08-22 23:46:40 +06:00
|
|
|
if (!AddObject(BG_RL_OBJECT_DOOR_1, BG_RL_OBJECT_TYPE_DOOR_1, 1293.561f, 1601.938f, 31.60557f, -1.457349f, 0, 0, -0.6658813f, 0.7460576f, RESPAWN_IMMEDIATELY)
|
|
|
|
|
|| !AddObject(BG_RL_OBJECT_DOOR_2, BG_RL_OBJECT_TYPE_DOOR_2, 1278.648f, 1730.557f, 31.60557f, 1.684245f, 0, 0, 0.7460582f, 0.6658807f, RESPAWN_IMMEDIATELY)
|
2008-10-05 08:48:32 -05:00
|
|
|
// buffs
|
2010-08-22 23:46:40 +06:00
|
|
|
|| !AddObject(BG_RL_OBJECT_BUFF_1, BG_RL_OBJECT_TYPE_BUFF_1, 1328.719971f, 1632.719971f, 36.730400f, -1.448624f, 0, 0, 0.6626201f, -0.7489557f, 120)
|
|
|
|
|
|| !AddObject(BG_RL_OBJECT_BUFF_2, BG_RL_OBJECT_TYPE_BUFF_2, 1243.300049f, 1699.170044f, 34.872601f, -0.06981307f, 0, 0, 0.03489945f, -0.9993908f, 120))
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
sLog.outErrorDb("BatteGroundRL: Failed to spawn some object!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
/*
|
|
|
|
|
Packet S->C, id 600, SMSG_INIT_WORLD_STATES (706), len 86
|
|
|
|
|
0000: 3C 02 00 00 80 0F 00 00 00 00 00 00 09 00 BA 0B | <...............
|
|
|
|
|
0010: 00 00 01 00 00 00 B9 0B 00 00 02 00 00 00 B8 0B | ................
|
|
|
|
|
0020: 00 00 00 00 00 00 D8 08 00 00 00 00 00 00 D7 08 | ................
|
|
|
|
|
0030: 00 00 00 00 00 00 D6 08 00 00 00 00 00 00 D5 08 | ................
|
|
|
|
|
0040: 00 00 00 00 00 00 D3 08 00 00 00 00 00 00 D4 08 | ................
|
|
|
|
|
0050: 00 00 00 00 00 00 | ......
|
|
|
|
|
*/
|