mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-25 04:55:54 +00:00
feat(Core/Battleground): split Arena and Battleground score (#10616)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "BattlegroundDS.h"
|
||||
#include "ArenaScore.h"
|
||||
#include "Creature.h"
|
||||
#include "GameObject.h"
|
||||
#include "Language.h"
|
||||
@@ -30,25 +31,8 @@ BattlegroundDS::BattlegroundDS()
|
||||
BgObjects.resize(BG_DS_OBJECT_MAX);
|
||||
BgCreatures.resize(BG_DS_NPC_MAX);
|
||||
|
||||
_waterfallTimer = 0;
|
||||
_waterfallStatus = 0;
|
||||
_waterfallKnockbackTimer = 0;
|
||||
_pipeKnockBackTimer = 0;
|
||||
_pipeKnockBackCount = 0;
|
||||
|
||||
StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M;
|
||||
StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
|
||||
StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S;
|
||||
StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE;
|
||||
//we must set messageIds
|
||||
StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_ARENA_ONE_MINUTE;
|
||||
StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_ARENA_THIRTY_SECONDS;
|
||||
StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_ARENA_FIFTEEN_SECONDS;
|
||||
StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
|
||||
}
|
||||
|
||||
BattlegroundDS::~BattlegroundDS()
|
||||
{
|
||||
}
|
||||
|
||||
void BattlegroundDS::PostUpdateImpl(uint32 diff)
|
||||
@@ -56,64 +40,58 @@ void BattlegroundDS::PostUpdateImpl(uint32 diff)
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
return;
|
||||
|
||||
if (getPipeKnockBackCount() < BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT)
|
||||
_events.Update(diff);
|
||||
|
||||
while (uint32 eventId = _events.ExecuteEvent())
|
||||
{
|
||||
if (getPipeKnockBackTimer() < diff)
|
||||
switch (eventId)
|
||||
{
|
||||
case BG_DS_EVENT_WATERFALL_WARNING:
|
||||
// Add the water
|
||||
DoorClose(BG_DS_OBJECT_WATER_2);
|
||||
_events.ScheduleEvent(BG_DS_EVENT_WATERFALL_ON, BG_DS_WATERFALL_WARNING_DURATION);
|
||||
break;
|
||||
case BG_DS_EVENT_WATERFALL_ON:
|
||||
// Active collision and start knockback timer
|
||||
DoorClose(BG_DS_OBJECT_WATER_1);
|
||||
_events.ScheduleEvent(BG_DS_EVENT_WATERFALL_OFF, BG_DS_WATERFALL_DURATION);
|
||||
_events.ScheduleEvent(BG_DS_EVENT_WATERFALL_KNOCKBACK, BG_DS_WATERFALL_KNOCKBACK_TIMER);
|
||||
break;
|
||||
case BG_DS_EVENT_WATERFALL_OFF:
|
||||
// Remove collision and water
|
||||
DoorOpen(BG_DS_OBJECT_WATER_1);
|
||||
DoorOpen(BG_DS_OBJECT_WATER_2);
|
||||
_events.CancelEvent(BG_DS_EVENT_WATERFALL_KNOCKBACK);
|
||||
_events.ScheduleEvent(BG_DS_EVENT_WATERFALL_WARNING, BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX);
|
||||
break;
|
||||
case BG_DS_EVENT_WATERFALL_KNOCKBACK:
|
||||
// Repeat knockback while the waterfall still active
|
||||
if (Creature* waterSpout = GetBGCreature(BG_DS_NPC_WATERFALL_KNOCKBACK))
|
||||
waterSpout->CastSpell(waterSpout, BG_DS_SPELL_WATER_SPOUT, true);
|
||||
_events.ScheduleEvent(eventId, BG_DS_WATERFALL_KNOCKBACK_TIMER);
|
||||
break;
|
||||
case BG_DS_EVENT_PIPE_KNOCKBACK:
|
||||
for (uint32 i = BG_DS_NPC_PIPE_KNOCKBACK_1; i <= BG_DS_NPC_PIPE_KNOCKBACK_2; ++i)
|
||||
if (Creature* waterSpout = GetBGCreature(i))
|
||||
waterSpout->CastSpell(waterSpout, BG_DS_SPELL_FLUSH, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_pipeKnockBackCount < BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT)
|
||||
{
|
||||
if (_pipeKnockBackTimer < diff)
|
||||
{
|
||||
for (uint32 i = BG_DS_NPC_PIPE_KNOCKBACK_1; i <= BG_DS_NPC_PIPE_KNOCKBACK_2; ++i)
|
||||
if (Creature* waterSpout = GetBgMap()->GetCreature(BgCreatures[i]))
|
||||
if (Creature* waterSpout = GetBGCreature(i))
|
||||
waterSpout->CastSpell(waterSpout, BG_DS_SPELL_FLUSH, true);
|
||||
|
||||
setPipeKnockBackCount(getPipeKnockBackCount() + 1);
|
||||
setPipeKnockBackTimer(BG_DS_PIPE_KNOCKBACK_DELAY);
|
||||
++_pipeKnockBackCount;
|
||||
_pipeKnockBackTimer = BG_DS_PIPE_KNOCKBACK_DELAY;
|
||||
}
|
||||
else
|
||||
setPipeKnockBackTimer(getPipeKnockBackTimer() - diff);
|
||||
_pipeKnockBackTimer -= diff;
|
||||
}
|
||||
|
||||
if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_ON) // Repeat knockback while the waterfall still active
|
||||
{
|
||||
if (getWaterFallKnockbackTimer() < diff)
|
||||
{
|
||||
if (Creature* waterSpout = GetBgMap()->GetCreature(BgCreatures[BG_DS_NPC_WATERFALL_KNOCKBACK]))
|
||||
waterSpout->CastSpell(waterSpout, BG_DS_SPELL_WATER_SPOUT, true);
|
||||
|
||||
setWaterFallKnockbackTimer(BG_DS_WATERFALL_KNOCKBACK_TIMER);
|
||||
}
|
||||
else
|
||||
setWaterFallKnockbackTimer(getWaterFallKnockbackTimer() - diff);
|
||||
}
|
||||
|
||||
if (getWaterFallTimer() < diff)
|
||||
{
|
||||
if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_OFF) // Add the water
|
||||
{
|
||||
DoorClose(BG_DS_OBJECT_WATER_2);
|
||||
setWaterFallTimer(BG_DS_WATERFALL_WARNING_DURATION);
|
||||
setWaterFallStatus(BG_DS_WATERFALL_STATUS_WARNING);
|
||||
}
|
||||
else if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_WARNING) // Active collision and perform knockback
|
||||
{
|
||||
if (GameObject* gob = GetBgMap()->GetGameObject(BgObjects[BG_DS_OBJECT_WATER_1]))
|
||||
gob->SetGoState(GO_STATE_READY);
|
||||
|
||||
setWaterFallTimer(BG_DS_WATERFALL_DURATION);
|
||||
setWaterFallStatus(BG_DS_WATERFALL_STATUS_ON);
|
||||
setWaterFallKnockbackTimer(BG_DS_WATERFALL_KNOCKBACK_TIMER);
|
||||
}
|
||||
else //if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_ON) // Remove collision and water
|
||||
{
|
||||
// turn off collision
|
||||
if (GameObject* gob = GetBgMap()->GetGameObject(BgObjects[BG_DS_OBJECT_WATER_1]))
|
||||
gob->SetGoState(GO_STATE_ACTIVE);
|
||||
|
||||
DoorOpen(BG_DS_OBJECT_WATER_2);
|
||||
setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
|
||||
setWaterFallStatus(BG_DS_WATERFALL_STATUS_OFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
setWaterFallTimer(getWaterFallTimer() - diff);
|
||||
}
|
||||
|
||||
void BattlegroundDS::StartingEventCloseDoors()
|
||||
@@ -130,11 +108,12 @@ void BattlegroundDS::StartingEventOpenDoors()
|
||||
for (uint32 i = BG_DS_OBJECT_BUFF_1; i <= BG_DS_OBJECT_BUFF_2; ++i)
|
||||
SpawnBGObject(i, 60);
|
||||
|
||||
setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
|
||||
setWaterFallStatus(BG_DS_WATERFALL_STATUS_OFF);
|
||||
_events.ScheduleEvent(BG_DS_EVENT_WATERFALL_WARNING, BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX);
|
||||
//for (uint8 i = 0; i < BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT; ++i)
|
||||
// _events.ScheduleEvent(BG_DS_EVENT_PIPE_KNOCKBACK, BG_DS_PIPE_KNOCKBACK_FIRST_DELAY + i * BG_DS_PIPE_KNOCKBACK_DELAY);
|
||||
|
||||
setPipeKnockBackTimer(BG_DS_PIPE_KNOCKBACK_FIRST_DELAY);
|
||||
setPipeKnockBackCount(0);
|
||||
_pipeKnockBackCount = 0;
|
||||
_pipeKnockBackTimer = BG_DS_PIPE_KNOCKBACK_FIRST_DELAY;
|
||||
|
||||
SpawnBGObject(BG_DS_OBJECT_WATER_2, RESPAWN_IMMEDIATELY);
|
||||
DoorOpen(BG_DS_OBJECT_WATER_2);
|
||||
@@ -149,39 +128,6 @@ void BattlegroundDS::StartingEventOpenDoors()
|
||||
itr->second->RemoveAurasDueToSpell(48018);
|
||||
}
|
||||
|
||||
void BattlegroundDS::AddPlayer(Player* player)
|
||||
{
|
||||
Battleground::AddPlayer(player);
|
||||
PlayerScores[player->GetGUID()] = new BattlegroundScore(player);
|
||||
Battleground::UpdateArenaWorldState();
|
||||
}
|
||||
|
||||
void BattlegroundDS::RemovePlayer(Player* /*player*/)
|
||||
{
|
||||
if (GetStatus() == STATUS_WAIT_LEAVE)
|
||||
return;
|
||||
|
||||
Battleground::UpdateArenaWorldState();
|
||||
CheckArenaWinConditions();
|
||||
}
|
||||
|
||||
void BattlegroundDS::HandleKillPlayer(Player* player, Player* killer)
|
||||
{
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
return;
|
||||
|
||||
if (!killer)
|
||||
{
|
||||
LOG_ERROR("bg.battleground", "BattlegroundDS: Killer player not found");
|
||||
return;
|
||||
}
|
||||
|
||||
Battleground::HandleKillPlayer(player, killer);
|
||||
|
||||
Battleground::UpdateArenaWorldState();
|
||||
CheckArenaWinConditions();
|
||||
}
|
||||
|
||||
void BattlegroundDS::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
{
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
@@ -192,13 +138,13 @@ void BattlegroundDS::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
case 5347:
|
||||
case 5348:
|
||||
// Remove effects of Demonic Circle Summon
|
||||
if (player->HasAura(48018))
|
||||
player->RemoveAurasDueToSpell(48018);
|
||||
if (player->HasAura(SPELL_WARL_DEMONIC_CIRCLE))
|
||||
player->RemoveAurasDueToSpell(SPELL_WARL_DEMONIC_CIRCLE);
|
||||
|
||||
// Someone has get back into the pipes and the knockback has already been performed,
|
||||
// so we reset the knockback count for kicking the player again into the arena.
|
||||
if (getPipeKnockBackCount() >= BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT)
|
||||
setPipeKnockBackCount(0);
|
||||
if (_pipeKnockBackCount >= BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT)
|
||||
_pipeKnockBackCount = 0;
|
||||
break;
|
||||
// OUTSIDE OF ARENA, TELEPORT!
|
||||
case 5328:
|
||||
@@ -218,6 +164,9 @@ void BattlegroundDS::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
case 5344: // -60
|
||||
player->NearTeleportTo(1330.0f, 800.0f, 3.16f, player->GetOrientation());
|
||||
break;
|
||||
/*default:
|
||||
Battleground::HandleAreaTrigger(player, trigger);
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,13 +179,7 @@ bool BattlegroundDS::HandlePlayerUnderMap(Player* player)
|
||||
void BattlegroundDS::FillInitialWorldStates(WorldPacket& data)
|
||||
{
|
||||
data << uint32(3610) << uint32(1); // 9 show
|
||||
Battleground::UpdateArenaWorldState();
|
||||
}
|
||||
|
||||
void BattlegroundDS::Init()
|
||||
{
|
||||
//call parent's class reset
|
||||
Battleground::Init();
|
||||
Arena::FillInitialWorldStates(data);
|
||||
}
|
||||
|
||||
bool BattlegroundDS::SetupBattleground()
|
||||
|
||||
Reference in New Issue
Block a user