Core/WorldStates: Migrate Tol Barad worldstates to new system

This commit is contained in:
Shauren authored and Ovahlord committed 2022-10-09 13:11:33 +02:00
1 parent 9f85a104d7
commit fe7e42b0b8
11 files changed
+151 -282

No files matched your search

@@ -0,0 +1,55 @@
DELETE FROM `world_state` WHERE `ID` IN (5332,5333,5334,5344,5346,5347,5348,5349,5350,5384,5385,5387,5418,5419,5420,5421,5422,5423,5424,5425,5426,5427,5428,5429,5430,5431,5432,5433,5434,5435,5436,5437,5438,5439,5440,5441,5442,5443,5444,5445,5446,5447,5451,5452,5453,5454,5455,5456,5469,5470,5546,5547,5684);
INSERT INTO `world_state` (`ID`, `DefaultValue`, `MapIDs`, `AreaIDs`, `ScriptName`, `Comment`) VALUES
(5332, 0, '732', '5095,5389', '', 'Tol Barad - Next battle start time'),
(5333, 0, '732', '5095', '', 'Tol Barad - Battle end time'),
(5334, 0, '732', '5095,5389', '', 'Tol Barad - Controlling faction'),
(5344, 0, '732', '5095', '', 'Tol Barad - In progress'),
(5346, 0, '732', '5095', '', 'Tol Barad - Show timer to battle end'),
(5347, 0, '732', '5095', '', 'Tol Barad - Number of destroyed towers'),
(5348, 0, '732', '5095', '', 'Tol Barad - Number of captured buildings'),
(5349, 0, '732', '5095', '', 'Tol Barad - Show number of captured buildings'),
(5350, 0, '732', '5095', '', 'Tol Barad - Show number of destroyed towers'),
(5384, 0, '732', '5095,5389', '', 'Tol Barad - Show if Horde is controlling'),
(5385, 0, '732', '5095,5389', '', 'Tol Barad - Show if Alliance is controlling'),
(5387, 0, '732', '5095,5389', '', 'Tol Barad - Show timer for next battle'),
(5418, 0, '732', '5095', '', 'Tol Barad - Ironclad Garrison controlled by Horde'),
(5419, 0, '732', '5095', '', 'Tol Barad - Ironclad Garrison being captured by Horde'),
(5420, 0, '732', '5095', '', 'Tol Barad - Ironclad Garrison neutral'),
(5421, 0, '732', '5095', '', 'Tol Barad - Ironclad Garrison being captured by Alliance'),
(5422, 0, '732', '5095', '', 'Tol Barad - Ironclad Garrison controlled by Alliance'),
(5423, 0, '732', '5095', '', 'Tol Barad - Warden\'s Vigil controlled by Horde'),
(5424, 0, '732', '5095', '', 'Tol Barad - Warden\'s Vigil being captured by Horde'),
(5425, 0, '732', '5095', '', 'Tol Barad - Warden\'s Vigil neutral'),
(5426, 0, '732', '5095', '', 'Tol Barad - Warden\'s Vigil being captured by Alliance'),
(5427, 0, '732', '5095', '', 'Tol Barad - Warden\'s Vigil controlled by Alliance'),
(5428, 0, '732', '5095', '', 'Tol Barad - Slagworks controlled by Horde'),
(5429, 0, '732', '5095', '', 'Tol Barad - Slagworks being captured by Horde'),
(5430, 0, '732', '5095', '', 'Tol Barad - Slagworks neutral'),
(5431, 0, '732', '5095', '', 'Tol Barad - Slagworks being captured by Alliance'),
(5432, 0, '732', '5095', '', 'Tol Barad - Slagworks controlled by Alliance'),
(5433, 0, '732', '5095', '', 'Tol Barad - West Spire Horde controlled'),
(5434, 0, '732', '5095', '', 'Tol Barad - West Spire Horde controlled, damaged'),
(5435, 0, '732', '5095', '', 'Tol Barad - West Spire destroyed'),
(5436, 0, '732', '5095', '', 'Tol Barad - West Spire Alliance controlled'),
(5437, 0, '732', '5095', '', 'Tol Barad - West Spire Alliance controlled, damaged'),
(5438, 0, '732', '5095', '', 'Tol Barad - South Spire Horde controlled'),
(5439, 0, '732', '5095', '', 'Tol Barad - South Spire Horde controlled, damaged'),
(5440, 0, '732', '5095', '', 'Tol Barad - South Spire destroyed'),
(5441, 0, '732', '5095', '', 'Tol Barad - South Spire Alliance controlled'),
(5442, 0, '732', '5095', '', 'Tol Barad - South Spire Alliance controlled, damaged'),
(5443, 0, '732', '5095', '', 'Tol Barad - East Spire Horde controlled'),
(5444, 0, '732', '5095', '', 'Tol Barad - East Spire Horde controlled, damaged'),
(5445, 0, '732', '5095', '', 'Tol Barad - East Spire destroyed'),
(5446, 0, '732', '5095', '', 'Tol Barad - East Spire Alliance controlled'),
(5447, 0, '732', '5095', '', 'Tol Barad - East Spire Alliance controlled, damaged'),
(5451, 0, '732', '5095', '', 'Tol Barad - East Spire uncontrolled'),
(5452, 0, '732', '5095', '', 'Tol Barad - East Spire damaged'),
(5453, 0, '732', '5095', '', 'Tol Barad - West Spire uncontrolled'),
(5454, 0, '732', '5095', '', 'Tol Barad - West Spire damaged'),
(5455, 0, '732', '5095', '', 'Tol Barad - South Spire uncontrolled'),
(5456, 0, '732', '5095', '', 'Tol Barad - South Spire damaged'),
(5469, 0, '732', '5095', '', 'Tol Barad - Baradin Hold controlled by Horde'),
(5470, 0, '732', '5095', '', 'Tol Barad - Baradin Hold controlled by Alliance'),
(5546, 0, '732', '5095,5389', '', 'Tol Barad - Show if Alliance is attacking'),
(5547, 0, '732', '5095,5389', '', 'Tol Barad - Show if Horde is attacking'),
(5684, 0, '732', '5095', '', 'Tol Barad - Preparation');
@@ -451,25 +451,6 @@ void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
sCreatureTextMgr->SendChat(stalker, id, target);
}
void Battlefield::SendInitWorldStatesTo(Player* player)
{
WorldPackets::WorldState::InitWorldStates packet;
packet.MapID = m_MapId;
packet.AreaID = m_ZoneId;
packet.SubareaID = player->GetAreaId();
FillInitialWorldStates(packet);
player->SendDirectMessage(packet.Write());
}
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
{
for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (auto itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
player->SendUpdateWorldState(field, value);
}
void Battlefield::RegisterZone(uint32 zoneId)
{
sBattlefieldMgr->AddZone(zoneId, this);
-11
View File
@@ -97,8 +97,6 @@ class TC_GAME_API BfCapturePoint
virtual ~BfCapturePoint() { }
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*data*/) { }
// Send world state update to all players present
void SendUpdateWorldState(uint32 field, uint32 value);
@@ -221,11 +219,6 @@ class TC_GAME_API Battlefield : public ZoneScript
/// Call this to init the Battlefield
virtual bool SetupBattlefield() { return true; }
void SendInitWorldStatesTo(Player* player);
/// Update data of a worldstate to all players present in zone
void SendUpdateWorldState(uint32 field, uint32 value);
/**
* \brief Called every time for update bf data and time
* - Update timer for start/end battle
@@ -343,10 +336,6 @@ class TC_GAME_API Battlefield : public ZoneScript
virtual void DoCompleteOrIncrementAchievement(uint32 /*achievement*/, Player* /*player*/, uint8 /*incrementNumber = 1*/) { }
/// Send all worldstate data to all player in zone.
virtual void SendInitWorldStatesToAll() = 0;
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*data*/) = 0;
/// Return if we can use mount in battlefield
bool CanFlyIn() { return !m_isActive; }
@@ -8789,7 +8789,6 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
uint32 mapid = GetMapId();
OutdoorPvP* pvp = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(zoneId);
InstanceScript* instance = GetInstanceScript();
Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(zoneId);
TC_LOG_DEBUG("network", "Sending SMSG_INIT_WORLD_STATES to Map: %u, Zone: %u", mapid, zoneId);
@@ -9391,29 +9390,12 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
if (bg && bg->GetTypeID(true) == BATTLEGROUND_BFG)
bg->FillInitialWorldStates(packet);
break;
// Tol Barad Peninsula
case 5389:
if (sWorld->getBoolConfig(CONFIG_TOLBARAD_ENABLE))
{
packet.Worldstates.emplace_back(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW, sWorld->getWorldState(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW));
packet.Worldstates.emplace_back(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW, sWorld->getWorldState(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW));
packet.Worldstates.emplace_back(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW, sWorld->getWorldState(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW));
packet.Worldstates.emplace_back(WS_BATTLEFIELD_TB_ALLIANCE_ATTACKING_SHOW, sWorld->getWorldState(WS_BATTLEFIELD_TB_ALLIANCE_ATTACKING_SHOW));
packet.Worldstates.emplace_back(WS_BATTLEFIELD_TB_HORDE_ATTACKING_SHOW, sWorld->getWorldState(WS_BATTLEFIELD_TB_HORDE_ATTACKING_SHOW));
}
break;
// Tol Barad
case 5095:
if (bf && bf->GetTypeId() == BATTLEFIELD_TB)
bf->FillInitialWorldStates(packet);
break;
default:
break;
}
SendDirectMessage(packet.Write());
SendBGWeekendWorldStates();
SendBattlefieldWorldStates();
}
void Player::SendBGWeekendWorldStates() const
@@ -9431,21 +9413,6 @@ void Player::SendBGWeekendWorldStates() const
}
}
void Player::SendBattlefieldWorldStates() const
{
/// Send misc stuff that needs to be sent on every login, like the battle timers.
if (sWorld->getBoolConfig(CONFIG_TOLBARAD_ENABLE))
{
if (Battlefield* tb = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_TB))
{
SendUpdateWorldState(WS_BATTLEFIELD_TB_FACTION_CONTROLLING, uint32(tb->GetDefenderTeam() + 1));
uint32 timer = tb->GetTimer() / 1000;
SendUpdateWorldState(WS_BATTLEFIELD_TB_TIME_BATTLE_END, uint32(tb->IsWarTime() ? uint32(GameTime::GetGameTime() + timer) : 0));
SendUpdateWorldState(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE, uint32(!tb->IsWarTime() ? uint32(GameTime::GetGameTime() + timer) : 0));
}
}
}
uint32 Player::GetXPRestBonus(uint32 xp)
{
uint32 rested_bonus = (uint32)GetRestBonus(); // xp for each rested bonus
-1
View File
@@ -2053,7 +2053,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SendUpdateWorldState(uint32 variable, uint32 value, bool hidden = false) const;
void SendDirectMessage(WorldPacket const* data) const;
void SendBGWeekendWorldStates() const;
void SendBattlefieldWorldStates() const;
void SendAurasForTarget(Unit* target) const;
@@ -4400,10 +4400,6 @@ enum WorldState : uint32
WS_BATTLEFIELD_TB_STATE_PREPARATIONS = 5684,
WS_BATTLEFIELD_TB_STATE_BATTLE = 5344,
WS_BATTLEFIELD_TB_PROGRESS_SHOW = 5376,
WS_BATTLEFIELD_TB_PROGRESS = 5377, // 0 horde, 100 alliance
WS_BATTLEFIELD_TB_PROGRESS_PERCENT_GREY = 5378,
WS_BATTLEFIELD_TB_KEEP_HORDE = 5469,
WS_BATTLEFIELD_TB_KEEP_ALLIANCE = 5470,
+94 -198
View File
@@ -35,7 +35,6 @@
#include "ScriptMgr.h"
#include "World.h"
#include "WorldStateMgr.h"
#include "WorldStatePackets.h"
const uint32 TBFactions[BG_TEAMS_COUNT] = { 1610, 1732 };
@@ -316,8 +315,16 @@ bool BattlefieldTB::SetupBattlefield()
// Set defender team
SetDefenderTeam(TeamId(sWorld->getWorldState(WS_BATTLEFIELD_TB_FACTION_CONTROLLING) - 1));
// Just to save world states
SendInitWorldStatesToAll();
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW, 1, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE, GameTime::GetGameTime() + m_Timer / IN_MILLISECONDS, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_FACTION_CONTROLLING, GetDefenderTeam() + 1, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW, GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW, GetDefenderTeam() == TEAM_HORDE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_KEEP_ALLIANCE, GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_KEEP_HORDE, GetDefenderTeam() == TEAM_HORDE ? 1 : 0, m_Map);
SaveWorldStateValues();
// Create capture points
for (uint8 i = 0; i < TB_BASE_COUNT; i++)
@@ -406,8 +413,7 @@ bool BattlefieldTB::Update(uint32 diff)
if (m_saveTimer <= diff)
{
if (!IsWarTime())
sWorld->setWorldState(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE, m_Timer);
SaveWorldStateValues();
m_saveTimer = 60 * IN_MILLISECONDS;
}
else
@@ -420,8 +426,6 @@ void BattlefieldTB::OnPlayerEnterZone(Player* player)
{
if (!m_isActive)
RemoveAurasFromPlayer(player);
SendInitWorldStatesTo(player);
}
void BattlefieldTB::OnPlayerLeaveZone(Player* player)
@@ -437,15 +441,14 @@ void BattlefieldTB::OnPlayerJoinWar(Player* player)
player->SetPvP(true);
// Bonus damage buff for attackers
if (player->GetTeam() == GetAttackerTeam() && GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED) > 0)
if (player->GetTeamId() == GetAttackerTeam())
{
CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
args.AddSpellMod(SPELLVALUE_AURA_STACK, GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED));
player->CastSpell(player, SPELL_TOWER_ATTACK_BONUS, args);
int32 towersDestroyed = sWorldStateMgr->GetValue(WS_BATTLEFIELD_TB_TOWERS_DESTROYED, m_Map);
if (towersDestroyed > 0)
player->CastSpell(player, SPELL_TOWER_ATTACK_BONUS, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_AURA_STACK, towersDestroyed));
}
}
void BattlefieldTB::OnPlayerLeaveWar(Player* player)
{
RemoveAurasFromPlayer(player);
@@ -459,165 +462,18 @@ void BattlefieldTB::RemoveAurasFromPlayer(Player* player)
player->RemoveAurasDueToSpell(SPELL_TB_SPIRITUAL_IMMUNITY);
}
// 62 fields, [7]-[68]
void BattlefieldTB::FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& packet)
void BattlefieldTB::SaveWorldStateValues()
{
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_ALLIANCE_ATTACKING_SHOW), int32(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_HORDE_ATTACKING_SHOW), int32(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0));
// Not sure if TB
//packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_9_UNKNOWN), int32(1));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_SOUTH_DAMAGED_NEUTRAL), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_SOUTH_INTACT_NEUTRAL), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_PROGRESS_SHOW), int32(0));
// Buildings/bases
for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
{
uint8 i = TB_BASE_COUNT;
switch (itr->second->GetCapturePointEntry())
{
case GO_CAPTURE_POINT_NORTH_A_DEFENDING:
case GO_CAPTURE_POINT_NORTH_H_DEFENDING:
i = TB_BASE_IRONCLAD_GARRISON;
break;
case GO_CAPTURE_POINT_EAST_A_DEFENDING:
case GO_CAPTURE_POINT_EAST_H_DEFENDING:
i = TB_BASE_SLAGWORKS;
break;
case GO_CAPTURE_POINT_WEST_A_DEFENDING:
case GO_CAPTURE_POINT_WEST_H_DEFENDING:
i = TB_BASE_WARDENS_VIGIL;
break;
default:
continue;
}
TeamId team = TEAM_NEUTRAL;
bool controlled = false;
bool capturing = false;
switch (itr->second->GetObjectiveState())
{
case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE:
controlled = true;
team = itr->second->GetTeamId();
break;
case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE:
team = TEAM_ALLIANCE;
capturing = true;
break;
case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE:
team = TEAM_HORDE;
capturing = true;
break;
default:
team = TEAM_NEUTRAL;
break;
}
packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsControlled[TEAM_ALLIANCE]), int32(team == TEAM_ALLIANCE && controlled ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsCapturing[TEAM_ALLIANCE]), int32(team == TEAM_ALLIANCE && capturing ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsNeutral), int32(team == TEAM_NEUTRAL ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsCapturing[TEAM_HORDE]), int32(team == TEAM_HORDE && capturing ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBCapturePoints[i].wsControlled[TEAM_HORDE]), int32(team == TEAM_HORDE && controlled ? 1 : 0));
}
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_TOWERS_DESTROYED_SHOW), int32(GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED)));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED_SHOW), int32(IsWarTime() ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED), int32(GetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED)));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_TOWERS_DESTROYED), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_TIME_BATTLE_END_SHOW), int32(IsWarTime() ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_STATE_BATTLE), int32(IsWarTime() ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_STATE_PREPARATIONS), int32(GetState() == BATTLEFIELD_WARMUP ? 1 : 0));
// Not sure if TB
//packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_35_UNKNOWN), int32(0));
//packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_36_UNKNOWN), int32(0));
//packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_37_UNKNOWN), int32(0));
// Unused tower icons
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_WEST_DAMAGED_NEUTRAL), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_WEST_INTACT_NEUTRAL), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_EAST_DAMAGED_NEUTRAL), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_EAST_INTACT_NEUTRAL), int32(0));
// Towers/spires
for (uint8 i = 0; i < TB_TOWERS_COUNT; i++)
{
// Find gameobject
for (ObjectGuid guid : Towers)
{
GameObject* tower = GetGameObject(guid);
if (!tower || tower->GetEntry() != TBTowers[i].entry)
continue;
TeamId team = GetDefenderTeam(); // 0-false -> alliance; 1-true -> horde
bool intact = tower->GetDestructibleState() == GO_DESTRUCTIBLE_INTACT;
bool damaged = tower->GetDestructibleState() == GO_DESTRUCTIBLE_DAMAGED;
bool destroyed = tower->GetDestructibleState() == GO_DESTRUCTIBLE_DESTROYED;
packet.Worldstates.emplace_back(uint32(TBTowers[i].wsIntact[TEAM_ALLIANCE]), int32(!team && intact ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDamaged[TEAM_ALLIANCE]), int32(!team && damaged ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDestroyed), int32(destroyed ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBTowers[i].wsDamaged[TEAM_HORDE]), int32(team && damaged ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TBTowers[i].wsIntact[TEAM_HORDE]), int32(team && intact ? 1 : 0));
}
}
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW), int32(!IsWarTime() ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_TIME_BATTLE_END), int32(IsWarTime() ? GameTime::GetGameTime() + (m_Timer / 1000) : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE), int32(!IsWarTime() ? GameTime::GetGameTime() + (m_Timer / 1000) : 0));
// Not sure if TB
//packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_65_UNKNOWN), int32(0));
//packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_66_UNKNOWN), int32(0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_KEEP_ALLIANCE), int32(GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(WS_BATTLEFIELD_TB_KEEP_HORDE), int32(GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
}
void BattlefieldTB::SendInitWorldStatesToAll()
{
// Save
sWorld->setWorldState(WS_BATTLEFIELD_TB_FACTION_CONTROLLING, uint32(GetDefenderTeam()));
sWorld->setWorldState(WS_BATTLEFIELD_TB_STATE_BATTLE, uint32(IsWarTime() ? 1 : 0));
sWorld->setWorldState(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW, uint32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
sWorld->setWorldState(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW, uint32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
sWorld->setWorldState(WS_BATTLEFIELD_TB_ALLIANCE_ATTACKING_SHOW, uint32(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0));
sWorld->setWorldState(WS_BATTLEFIELD_TB_HORDE_ATTACKING_SHOW, uint32(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0));
sWorld->setWorldState(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE, uint32(!IsWarTime() ? m_Timer : 0));
sWorld->setWorldState(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW, uint32(!IsWarTime() ? 1 : 0));
// Tol Barad
for (uint8 team = 0; team < 2; team++)
for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(*itr))
SendInitWorldStatesTo(player);
// Tol Barad Peninsula
Map::PlayerList const& players = m_Map->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if (Player* player = itr->GetSource()->ToPlayer())
if (player->GetZoneId() == 5389) // ZONE_TOL_BARAD_PENINSULA
player->SendInitWorldStates(5389, player->GetAreaId());
}
void BattlefieldTB::OnStartGrouping()
{
UpdateNPCsAndGameObjects();
SendUpdateWorldState(WS_BATTLEFIELD_TB_STATE_PREPARATIONS, uint32(1));
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_STATE_PREPARATIONS, 1, m_Map);
// Teleport players out of questing area
for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
@@ -627,18 +483,45 @@ void BattlefieldTB::OnStartGrouping()
player->CastSpell(player, TBQuestAreas[m_iCellblockRandom].teleportSpell, true);
// Should we also teleport players out of Baradin Hold underground area?
};
}
void BattlefieldTB::OnBattleStart()
{
SetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED, uint32(0));
SetData(BATTLEFIELD_TB_DATA_TOWERS_INTACT, uint32(3));
SetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED, uint32(0));
UpdateNPCsAndGameObjects();
SendInitWorldStatesToAll();
};
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_BATTLE_END_SHOW, 1, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_BATTLE_END, GameTime::GetGameTime() + m_Timer / IN_MILLISECONDS, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_ALLIANCE_ATTACKING_SHOW, GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_HORDE_ATTACKING_SHOW, GetAttackerTeam() == TEAM_HORDE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED_SHOW, 1, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TOWERS_DESTROYED_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TOWERS_DESTROYED, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_STATE_PREPARATIONS, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_STATE_BATTLE, 1, m_Map);
// Towers/spires
for (uint8 i = 0; i < TB_TOWERS_COUNT; i++)
{
sWorldStateMgr->SetValue(TBTowers[i].wsIntact[GetDefenderTeam()], 1, m_Map);
sWorldStateMgr->SetValue(TBTowers[i].wsDamaged[GetDefenderTeam()], 0, m_Map);
sWorldStateMgr->SetValue(TBTowers[i].wsDestroyed, 0, m_Map);
sWorldStateMgr->SetValue(TBTowers[i].wsDamaged[GetAttackerTeam()], 0, m_Map);
sWorldStateMgr->SetValue(TBTowers[i].wsIntact[GetAttackerTeam()], 0, m_Map);
}
}
void BattlefieldTB::OnBattleEnd(bool endByTimer)
{
@@ -674,8 +557,25 @@ void BattlefieldTB::OnBattleEnd(bool endByTimer)
warnedTwoMinutes = false;
warnedOneMinute = false;
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_BATTLE_END_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_BATTLE_END, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE_SHOW, 1, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_NEXT_BATTLE, GameTime::GetGameTime() + m_NoWarBattleTime / IN_MILLISECONDS, m_Map);
};
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_ALLIANCE_ATTACKING_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_HORDE_ATTACKING_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_FACTION_CONTROLLING, GetDefenderTeam() + 1, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_ALLIANCE_CONTROLS_SHOW, GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_HORDE_CONTROLS_SHOW, GetDefenderTeam() == TEAM_HORDE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_KEEP_ALLIANCE, GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_KEEP_HORDE, GetDefenderTeam() == TEAM_HORDE ? 1 : 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED_SHOW, 0, m_Map);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_STATE_BATTLE, 0, m_Map);
}
void BattlefieldTB::UpdateNPCsAndGameObjects()
{
@@ -803,7 +703,7 @@ void BattlefieldTB::UpdateNPCsAndGameObjects()
for (uint8 i = 0; i < BATTLEFIELD_TB_GRAVEYARD_MAX; i++)
if (BfGraveyard* graveyard = GetGraveyardById(i))
graveyard->GiveControlTo(!IsWarTime() || TBGraveyards[i].defenderControls ? GetDefenderTeam() : GetAttackerTeam());
};
}
void BattlefieldTB::OnCreatureCreate(Creature* creature)
{
@@ -860,7 +760,7 @@ void BattlefieldTB::OnCreatureCreate(Creature* creature)
default:
break;
}
};
}
void BattlefieldTB::OnGameObjectCreate(GameObject* go)
{
@@ -901,7 +801,7 @@ void BattlefieldTB::OnGameObjectCreate(GameObject* go)
default:
break;
}
};
}
void BattlefieldTB::ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject* /*invoker*/)
{
@@ -952,8 +852,8 @@ void BattlefieldTB::TowerDamaged(TBTowerId tbTowerId)
SetData(BATTLEFIELD_TB_DATA_TOWERS_INTACT, GetData(BATTLEFIELD_TB_DATA_TOWERS_INTACT) - 1);
SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsIntact[GetDefenderTeam()]), int32(0));
SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsDamaged[GetDefenderTeam()]), int32(1));
sWorldStateMgr->SetValue(TBTowers[tbTowerId].wsIntact[GetDefenderTeam()], 0, m_Map);
sWorldStateMgr->SetValue(TBTowers[tbTowerId].wsDamaged[GetDefenderTeam()], 1, m_Map);
TeamCastSpell(GetAttackerTeam(), SPELL_REWARD_TOWER_DAMAGED);
}
@@ -965,27 +865,21 @@ void BattlefieldTB::TowerDestroyed(TBTowerId tbTowerId)
// Add 5 minute bonus time
m_Timer += m_BonusTime;
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TIME_BATTLE_END, GameTime::GetGameTime() + m_Timer / IN_MILLISECONDS, m_Map);
SendUpdateWorldState(WS_BATTLEFIELD_TB_TIME_BATTLE_END, uint32(GameTime::GetGameTime() + (m_Timer / 1000)));
SendWarning(TBTowers[tbTowerId].textDestroyed);
SendWarning(TBTowers[tbTowerId].textDamaged);
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TOWERS_DESTROYED_SHOW, 1, m_Map);
int32 towersDestroyed = sWorldStateMgr->GetValue(WS_BATTLEFIELD_TB_TOWERS_DESTROYED, m_Map) + 1;
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_TOWERS_DESTROYED, towersDestroyed, m_Map);
SetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED, GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED) + 1);
SendUpdateWorldState(uint32(WS_BATTLEFIELD_TB_TOWERS_DESTROYED), int32(GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED)));
SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsDamaged[GetDefenderTeam()]), int32(0));
SendUpdateWorldState(uint32(TBTowers[tbTowerId].wsDestroyed), int32(1));
sWorldStateMgr->SetValue(TBTowers[tbTowerId].wsDamaged[GetDefenderTeam()], 0, m_Map);
sWorldStateMgr->SetValue(TBTowers[tbTowerId].wsDestroyed, 1, m_Map);
// Attack bonus buff
for (auto itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
{
if (Player* player = ObjectAccessor::FindPlayer(*itr))
{
CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
args.AddSpellMod(SPELLVALUE_AURA_STACK, GetData(BATTLEFIELD_TB_DATA_TOWERS_DESTROYED));
player->CastSpell(player, SPELL_TOWER_ATTACK_BONUS, args);
}
}
for (ObjectGuid const& guid : m_PlayersInWar[GetAttackerTeam()])
if (Player* player = ObjectAccessor::FindPlayer(guid))
player->CastSpell(player, SPELL_TOWER_ATTACK_BONUS, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_AURA_STACK, towersDestroyed));
// Honor reward
TeamCastSpell(GetAttackerTeam(), SPELL_REWARD_TOWER_DESTROYED);
@@ -999,8 +893,7 @@ void BattlefieldTB::UpdateCapturedBaseCount()
if (itr->second->GetTeamId() == GetAttackerTeam())
numCapturedBases += 1;
SetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED, numCapturedBases);
SendUpdateWorldState(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED, uint32(numCapturedBases));
sWorldStateMgr->SetValue(WS_BATTLEFIELD_TB_BUILDINGS_CAPTURED, numCapturedBases, m_Map);
// Check if attackers won
if (numCapturedBases == TB_BASE_COUNT)
@@ -1036,8 +929,11 @@ TolBaradCapturePoint::TolBaradCapturePoint(BattlefieldTB* battlefield, TeamId te
m_State = teamInControl == TEAM_ALLIANCE ? BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE : BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE;
}
void TolBaradCapturePoint::ChangeTeam(TeamId /*oldTeam*/)
void TolBaradCapturePoint::SendChangePhase()
{
if (m_OldState == m_State)
return;
// Find out index
uint8 iBase = TB_BASE_COUNT;
for (uint8 i = 0; i < TB_BASE_COUNT; i++)
@@ -1052,15 +948,15 @@ void TolBaradCapturePoint::ChangeTeam(TeamId /*oldTeam*/)
{
case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE:
SendUpdateWorldState(TBCapturePoints[iBase].wsControlled[GetTeamId()], uint32(0));
sWorldStateMgr->SetValue(TBCapturePoints[iBase].wsControlled[GetTeamId()], 0, m_Bf->GetMap());
break;
case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE:
SendUpdateWorldState(TBCapturePoints[iBase].wsCapturing[TEAM_ALLIANCE], uint32(0));
sWorldStateMgr->SetValue(TBCapturePoints[iBase].wsCapturing[TEAM_ALLIANCE], 0, m_Bf->GetMap());
break;
case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE:
SendUpdateWorldState(TBCapturePoints[iBase].wsCapturing[TEAM_HORDE], uint32(0));
sWorldStateMgr->SetValue(TBCapturePoints[iBase].wsCapturing[TEAM_HORDE], 0, m_Bf->GetMap());
break;
default:
break;
@@ -1072,21 +968,21 @@ void TolBaradCapturePoint::ChangeTeam(TeamId /*oldTeam*/)
case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE:
case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE:
m_Bf->SendWarning(TBCapturePoints[iBase].textGained[GetTeamId()]);
SendUpdateWorldState(TBCapturePoints[iBase].wsControlled[GetTeamId()], uint32(1));
sWorldStateMgr->SetValue(TBCapturePoints[iBase].wsControlled[GetTeamId()], 1, m_Bf->GetMap());
GetCapturePointGo()->SetGoArtKit(GetTeamId() == TEAM_ALLIANCE ? TB_GO_ARTKIT_FLAG_ALLIANCE : TB_GO_ARTKIT_FLAG_HORDE);
break;
case BF_CAPTUREPOINT_OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE:
m_Bf->SendWarning(TBCapturePoints[iBase].textLost[TEAM_HORDE]);
[[fallthrough]];
case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE:
SendUpdateWorldState(TBCapturePoints[iBase].wsCapturing[TEAM_ALLIANCE], uint32(1));
sWorldStateMgr->SetValue(TBCapturePoints[iBase].wsCapturing[TEAM_ALLIANCE], 1, m_Bf->GetMap());
GetCapturePointGo()->SetGoArtKit(TB_GO_ARTKIT_FLAG_NONE);
break;
case BF_CAPTUREPOINT_OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE:
m_Bf->SendWarning(TBCapturePoints[iBase].textLost[TEAM_ALLIANCE]);
[[fallthrough]];
case BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE:
SendUpdateWorldState(TBCapturePoints[iBase].wsCapturing[TEAM_HORDE], uint32(1));
sWorldStateMgr->SetValue(TBCapturePoints[iBase].wsCapturing[TEAM_HORDE], 1, m_Bf->GetMap());
GetCapturePointGo()->SetGoArtKit(TB_GO_ARTKIT_FLAG_NONE);
break;
default:
@@ -39,9 +39,7 @@ enum TolBaradInfo
enum TolBaradData
{
BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED,
BATTLEFIELD_TB_DATA_TOWERS_INTACT,
BATTLEFIELD_TB_DATA_TOWERS_DESTROYED,
BATTLEFIELD_TB_DATA_MAX,
};
@@ -338,7 +336,7 @@ class TolBaradCapturePoint : public BfCapturePoint
public:
TolBaradCapturePoint(BattlefieldTB* battlefield, TeamId teamInControl);
void ChangeTeam(TeamId /*oldteam*/) override;
void SendChangePhase() override;
};
/* ##################### *
@@ -374,8 +372,7 @@ class BattlefieldTB : public Battlefield
bool SetupBattlefield() override;
void SendInitWorldStatesToAll() override;
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*data*/) override;
void SaveWorldStateValues();
void HandleKill(Player* killer, Unit* victim) override;
//void OnUnitDeath(Unit* unit) override;
@@ -40,7 +40,6 @@
#include "World.h"
#include "WorldSession.h"
#include "WorldStateMgr.h"
#include "WorldStatePackets.h"
struct BfWGCoordGY
{
@@ -637,7 +636,6 @@ void BattlefieldWG::OnBattleStart()
player->GetPosition(x, y, z);
if (5500 > x && x > 5392 && y < 2880 && y > 2800 && z < 480)
player->TeleportTo(571, 5349.8686f, 2838.481f, 409.240f, 0.046328f);
SendInitWorldStatesTo(player);
}
}
}
@@ -1110,7 +1108,6 @@ void BattlefieldWG::OnPlayerJoinWar(Player* player)
if (GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT) > 0)
player->SetAuraStack(SPELL_TOWER_CONTROL, player, GetData(BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT));
}
SendInitWorldStatesTo(player);
}
void BattlefieldWG::OnPlayerLeaveWar(Player* player)
@@ -1148,8 +1145,6 @@ void BattlefieldWG::OnPlayerEnterZone(Player* player)
RemoveAurasFromPlayer(player);
player->AddAura(m_DefenderTeam == TEAM_HORDE ? SPELL_HORDE_CONTROL_PHASE_SHIFT : SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, player);
// Send worldstate to player
SendInitWorldStatesTo(player);
}
uint32 BattlefieldWG::GetData(uint32 data) const
@@ -334,11 +334,6 @@ class BattlefieldWG : public Battlefield
void UpdateVehicleCountWG();
void UpdateCounterVehicle(bool init);
// TODO: delete
void SendInitWorldStatesToAll() override { }
// TODO: delete
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*packet*/) override { }
void HandleKill(Player* killer, Unit* victim) override;
void OnUnitDeath(Unit* unit) override;
void HandlePromotion(Player* killer, Unit* killed);
-1
View File
@@ -165,7 +165,6 @@ public:
return false;
bf->SetTimer(time * IN_MILLISECONDS);
bf->SendInitWorldStatesToAll();
if (battleid == 1)
handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");