Enable areatrigger teleports in battleground
Idea by @joschiwald Also cleanup and unify related code
This commit is contained in:
parent
c453b05106
commit
baf374d2f9
@ -991,7 +991,7 @@ class BattleGround
|
|||||||
* @param
|
* @param
|
||||||
* @param uint32
|
* @param uint32
|
||||||
*/
|
*/
|
||||||
virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) {}
|
virtual bool HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { return false; }
|
||||||
// must be implemented in BG subclass if need AND call base class generic code
|
// must be implemented in BG subclass if need AND call base class generic code
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -200,7 +200,7 @@ void BattleGroundAB::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/)
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The source.</param>
|
/// <param name="source">The source.</param>
|
||||||
/// <param name="trigger">The trigger.</param>
|
/// <param name="trigger">The trigger.</param>
|
||||||
void BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
|
bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||||
{
|
{
|
||||||
switch (trigger)
|
switch (trigger)
|
||||||
{
|
{
|
||||||
@ -216,19 +216,13 @@ void BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
|
|||||||
else
|
else
|
||||||
{ source->LeaveBattleground(); }
|
{ source->LeaveBattleground(); }
|
||||||
break;
|
break;
|
||||||
case 3866: // Stables
|
|
||||||
case 3869: // Gold Mine
|
|
||||||
case 3867: // Farm
|
|
||||||
case 3868: // Lumber Mill
|
|
||||||
case 3870: // Black Smith
|
|
||||||
case 4020: // Unk1
|
|
||||||
case 4021: // Unk2
|
|
||||||
// break;
|
// break;
|
||||||
default:
|
default:
|
||||||
// sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
|
// sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||||
// source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
// source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -255,7 +255,7 @@ class BattleGroundAB : public BattleGround
|
|||||||
* @param source
|
* @param source
|
||||||
* @param trigger
|
* @param trigger
|
||||||
*/
|
*/
|
||||||
void HandleAreaTrigger(Player* source, uint32 trigger) override;
|
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
|
@ -348,7 +348,7 @@ void BattleGroundAV::EndBattleGround(Team winner)
|
|||||||
BattleGround::EndBattleGround(winner);
|
BattleGround::EndBattleGround(winner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
|
bool BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||||
{
|
{
|
||||||
// this is wrong way to implement these things. On official it done by gameobject spell cast.
|
// this is wrong way to implement these things. On official it done by gameobject spell cast.
|
||||||
switch (trigger)
|
switch (trigger)
|
||||||
@ -366,19 +366,12 @@ void BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
|
|||||||
else
|
else
|
||||||
{ source->LeaveBattleground(); }
|
{ source->LeaveBattleground(); }
|
||||||
break;
|
break;
|
||||||
case 3326:
|
|
||||||
case 3327:
|
|
||||||
case 3328:
|
|
||||||
case 3329:
|
|
||||||
case 3330:
|
|
||||||
case 3331:
|
|
||||||
// source->Unmount();
|
// source->Unmount();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
DEBUG_LOG("BattleGroundAV: WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
|
|
||||||
// source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
// source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGroundAV::UpdatePlayerScore(Player* source, uint32 type, uint32 value)
|
void BattleGroundAV::UpdatePlayerScore(Player* source, uint32 type, uint32 value)
|
||||||
|
@ -428,7 +428,7 @@ class BattleGroundAV : public BattleGround
|
|||||||
* @param source
|
* @param source
|
||||||
* @param trigger
|
* @param trigger
|
||||||
*/
|
*/
|
||||||
void HandleAreaTrigger(Player* source, uint32 trigger) override;
|
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
|
@ -455,23 +455,16 @@ void BattleGroundWS::UpdateTeamScore(Team team)
|
|||||||
UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, m_TeamScores[TEAM_INDEX_HORDE]);
|
UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, m_TeamScores[TEAM_INDEX_HORDE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
|
bool BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||||
{
|
{
|
||||||
// this is wrong way to implement these things. On official it done by gameobject spell cast.
|
// this is wrong way to implement these things. On official it done by gameobject spell cast.
|
||||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||||
{ return; }
|
{ return false; }
|
||||||
|
|
||||||
// uint32 SpellId = 0;
|
// uint32 SpellId = 0;
|
||||||
// uint64 buff_guid = 0;
|
// uint64 buff_guid = 0;
|
||||||
switch (trigger)
|
switch (trigger)
|
||||||
{
|
{
|
||||||
case 3686: // Alliance elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update().
|
|
||||||
case 3687: // Horde elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update().
|
|
||||||
case 3706: // Alliance elixir of regeneration spawn
|
|
||||||
case 3708: // Horde elixir of regeneration spawn
|
|
||||||
case 3707: // Alliance elixir of berserk spawn
|
|
||||||
case 3709: // Horde elixir of berserk spawn
|
|
||||||
break;
|
|
||||||
case 3646: // Alliance Flag spawn
|
case 3646: // Alliance Flag spawn
|
||||||
if (m_FlagState[TEAM_INDEX_HORDE] && !m_FlagState[TEAM_INDEX_ALLIANCE])
|
if (m_FlagState[TEAM_INDEX_HORDE] && !m_FlagState[TEAM_INDEX_ALLIANCE])
|
||||||
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
|
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
|
||||||
@ -495,10 +488,9 @@ void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
|
|||||||
{ source->LeaveBattleground(); }
|
{ source->LeaveBattleground(); }
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
|
return false;
|
||||||
source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleGroundWS::Reset()
|
void BattleGroundWS::Reset()
|
||||||
|
@ -276,7 +276,7 @@ class BattleGroundWS : public BattleGround
|
|||||||
* @param source
|
* @param source
|
||||||
* @param trigger
|
* @param trigger
|
||||||
*/
|
*/
|
||||||
void HandleAreaTrigger(Player* source, uint32 trigger) override;
|
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
|
@ -698,22 +698,24 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recv_data)
|
|||||||
|
|
||||||
void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
uint32 Trigger_ID;
|
|
||||||
recv_data >> Trigger_ID;
|
|
||||||
|
|
||||||
DEBUG_LOG("WORLD: Received opcode CMSG_AREATRIGGER");
|
DEBUG_LOG("WORLD: Received opcode CMSG_AREATRIGGER");
|
||||||
DEBUG_LOG("Trigger ID: %u", Trigger_ID);
|
|
||||||
|
|
||||||
if (_player->IsTaxiFlying())
|
uint32 Trigger_ID;
|
||||||
|
|
||||||
|
recv_data >> Trigger_ID;
|
||||||
|
DEBUG_LOG("Trigger ID: %u", Trigger_ID);
|
||||||
|
Player* player = GetPlayer();
|
||||||
|
|
||||||
|
if (player->IsTaxiFlying())
|
||||||
{
|
{
|
||||||
DEBUG_LOG("%s in flight, ignore Area Trigger ID: %u", _player->GetGuidStr().c_str(), Trigger_ID);
|
DEBUG_LOG("Player '%s' (GUID: %u) in flight, ignore Area Trigger ID: %u", player->GetName(), player->GetGUIDLow(), Trigger_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
|
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
|
||||||
if (!atEntry)
|
if (!atEntry)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("%s send unknown (by DBC) Area Trigger ID: %u", _player->GetGuidStr().c_str(), Trigger_ID);
|
DEBUG_LOG("Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID: %u", player->GetName(), player->GetGUIDLow(), Trigger_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,23 +723,23 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
|||||||
const float delta = 5.0f;
|
const float delta = 5.0f;
|
||||||
|
|
||||||
// check if player in the range of areatrigger
|
// check if player in the range of areatrigger
|
||||||
if (!IsPointInAreaTriggerZone(atEntry, _player->GetMapId(), _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), delta))
|
if (!IsPointInAreaTriggerZone(atEntry, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), delta))
|
||||||
{
|
{
|
||||||
DEBUG_LOG("%s too far, ignore Area Trigger ID: %u", _player->GetGuidStr().c_str(), Trigger_ID);
|
DEBUG_LOG("Player '%s' (GUID: %u) too far, ignore Area Trigger ID: %u", player->GetName(), player->GetGUIDLow(), Trigger_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sScriptMgr.OnAreaTrigger(_player, atEntry))
|
if (sScriptMgr.OnAreaTrigger(player, atEntry))
|
||||||
{ return; }
|
{ return; }
|
||||||
|
|
||||||
uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(Trigger_ID);
|
uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(Trigger_ID);
|
||||||
if (quest_id && _player->IsAlive() && _player->IsActiveQuest(quest_id))
|
if (quest_id && player->IsAlive() && player->IsActiveQuest(quest_id))
|
||||||
{
|
{
|
||||||
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
|
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
|
||||||
if (pQuest)
|
if (pQuest)
|
||||||
{
|
{
|
||||||
if (_player->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE)
|
if (player->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE)
|
||||||
{ _player->AreaExploredOrEventHappens(quest_id); }
|
{ player->AreaExploredOrEventHappens(quest_id); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,19 +747,19 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
|||||||
if (sObjectMgr.IsTavernAreaTrigger(Trigger_ID))
|
if (sObjectMgr.IsTavernAreaTrigger(Trigger_ID))
|
||||||
{
|
{
|
||||||
// set resting flag we are in the inn
|
// set resting flag we are in the inn
|
||||||
if (_player->GetRestType() != REST_TYPE_IN_CITY)
|
if (player->GetRestType() != REST_TYPE_IN_CITY)
|
||||||
{ _player->SetRestType(REST_TYPE_IN_TAVERN, Trigger_ID); }
|
player->SetRestType(REST_TYPE_IN_TAVERN, Trigger_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BattleGround* bg = _player->GetBattleGround())
|
if (BattleGround* bg = player->GetBattleGround())
|
||||||
{
|
{
|
||||||
bg->HandleAreaTrigger(_player, Trigger_ID);
|
if (bg->HandleAreaTrigger(player, Trigger_ID))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(_player->GetCachedZoneId()))
|
else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId()))
|
||||||
{
|
{
|
||||||
if (outdoorPvP->HandleAreaTrigger(_player, Trigger_ID))
|
if (outdoorPvP->HandleAreaTrigger(player, Trigger_ID))
|
||||||
{ return; }
|
{ return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,10 +773,10 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
|||||||
{ return; }
|
{ return; }
|
||||||
|
|
||||||
// ghost resurrected at enter attempt to dungeon with corpse (including fail enter cases)
|
// ghost resurrected at enter attempt to dungeon with corpse (including fail enter cases)
|
||||||
if (!_player->IsAlive() && targetMapEntry->IsDungeon())
|
if (!player->IsAlive() && targetMapEntry->IsDungeon())
|
||||||
{
|
{
|
||||||
uint32 corpseMapId = 0; // was planned to be negative as "incorrect" id? anyway map 0 is not instanceable
|
uint32 corpseMapId = 0; // was planned to be negative as "incorrect" id? anyway map 0 is not instanceable
|
||||||
if (Corpse* corpse = _player->GetCorpse())
|
if (Corpse* corpse = player->GetCorpse())
|
||||||
{ corpseMapId = corpse->GetMapId(); }
|
{ corpseMapId = corpse->GetMapId(); }
|
||||||
|
|
||||||
// check back way from corpse to entrance
|
// check back way from corpse to entrance
|
||||||
@ -793,8 +795,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
|||||||
// corpse not in dungeon or some linked deep dungeons
|
// corpse not in dungeon or some linked deep dungeons
|
||||||
if (!instance_map)
|
if (!instance_map)
|
||||||
{
|
{
|
||||||
_player->GetSession()->SendAreaTriggerMessage("You can not enter %s while in a ghost mode",
|
player->GetSession()->SendAreaTriggerMessage("You can not enter %s while in a ghost mode",
|
||||||
targetMapEntry->name[_player->GetSession()->GetSessionDbcLocale()]);
|
targetMapEntry->name[player->GetSession()->GetSessionDbcLocale()]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,20 +813,20 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now we can resurrect player, and then check teleport requirements
|
// now we can resurrect player, and then check teleport requirements
|
||||||
_player->ResurrectPlayer(0.5f);
|
player->ResurrectPlayer(0.5f);
|
||||||
_player->SpawnCorpseBones();
|
player->SpawnCorpseBones();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 miscRequirement = 0;
|
uint32 miscRequirement = 0;
|
||||||
AreaLockStatus lockStatus = _player->GetAreaTriggerLockStatus(at, miscRequirement);
|
AreaLockStatus lockStatus = player->GetAreaTriggerLockStatus(at, miscRequirement);
|
||||||
if (lockStatus != AREA_LOCKSTATUS_OK)
|
if (lockStatus != AREA_LOCKSTATUS_OK)
|
||||||
{
|
{
|
||||||
_player->SendTransferAbortedByLockStatus(targetMapEntry, lockStatus, miscRequirement);
|
player->SendTransferAbortedByLockStatus(targetMapEntry, lockStatus, miscRequirement);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// teleport player
|
// teleport player
|
||||||
_player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT, true);
|
player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data)
|
void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user