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 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
|
||||
/**
|
||||
* @brief
|
||||
|
@ -200,7 +200,7 @@ void BattleGroundAB::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/)
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <param name="trigger">The trigger.</param>
|
||||
void BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||
bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||
{
|
||||
switch (trigger)
|
||||
{
|
||||
@ -216,19 +216,13 @@ void BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||
else
|
||||
{ source->LeaveBattleground(); }
|
||||
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;
|
||||
default:
|
||||
// sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||
// source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -255,7 +255,7 @@ class BattleGroundAB : public BattleGround
|
||||
* @param source
|
||||
* @param trigger
|
||||
*/
|
||||
void HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -348,7 +348,7 @@ void BattleGroundAV::EndBattleGround(Team 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.
|
||||
switch (trigger)
|
||||
@ -366,19 +366,12 @@ void BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||
else
|
||||
{ source->LeaveBattleground(); }
|
||||
break;
|
||||
case 3326:
|
||||
case 3327:
|
||||
case 3328:
|
||||
case 3329:
|
||||
case 3330:
|
||||
case 3331:
|
||||
// source->Unmount();
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("BattleGroundAV: 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)
|
||||
|
@ -428,7 +428,7 @@ class BattleGroundAV : public BattleGround
|
||||
* @param source
|
||||
* @param trigger
|
||||
*/
|
||||
void HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -455,23 +455,16 @@ void BattleGroundWS::UpdateTeamScore(Team team)
|
||||
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.
|
||||
if (GetStatus() != STATUS_IN_PROGRESS)
|
||||
{ return; }
|
||||
{ return false; }
|
||||
|
||||
// uint32 SpellId = 0;
|
||||
// uint64 buff_guid = 0;
|
||||
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
|
||||
if (m_FlagState[TEAM_INDEX_HORDE] && !m_FlagState[TEAM_INDEX_ALLIANCE])
|
||||
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
|
||||
@ -495,10 +488,9 @@ void BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
|
||||
{ source->LeaveBattleground(); }
|
||||
break;
|
||||
default:
|
||||
sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||
source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", trigger);
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BattleGroundWS::Reset()
|
||||
|
@ -276,7 +276,7 @@ class BattleGroundWS : public BattleGround
|
||||
* @param source
|
||||
* @param trigger
|
||||
*/
|
||||
void HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
@ -698,22 +698,24 @@ void WorldSession::HandleResurrectResponseOpcode(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("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;
|
||||
}
|
||||
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -721,23 +723,23 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
const float delta = 5.0f;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (sScriptMgr.OnAreaTrigger(_player, atEntry))
|
||||
if (sScriptMgr.OnAreaTrigger(player, atEntry))
|
||||
{ return; }
|
||||
|
||||
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);
|
||||
if (pQuest)
|
||||
{
|
||||
if (_player->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE)
|
||||
{ _player->AreaExploredOrEventHappens(quest_id); }
|
||||
if (player->GetQuestStatus(quest_id) == QUEST_STATUS_INCOMPLETE)
|
||||
{ player->AreaExploredOrEventHappens(quest_id); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,19 +747,19 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
if (sObjectMgr.IsTavernAreaTrigger(Trigger_ID))
|
||||
{
|
||||
// set resting flag we are in the inn
|
||||
if (_player->GetRestType() != REST_TYPE_IN_CITY)
|
||||
{ _player->SetRestType(REST_TYPE_IN_TAVERN, Trigger_ID); }
|
||||
if (player->GetRestType() != REST_TYPE_IN_CITY)
|
||||
player->SetRestType(REST_TYPE_IN_TAVERN, Trigger_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (BattleGround* bg = _player->GetBattleGround())
|
||||
if (BattleGround* bg = player->GetBattleGround())
|
||||
{
|
||||
bg->HandleAreaTrigger(_player, Trigger_ID);
|
||||
if (bg->HandleAreaTrigger(player, Trigger_ID))
|
||||
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; }
|
||||
}
|
||||
|
||||
@ -771,10 +773,10 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
{ return; }
|
||||
|
||||
// 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
|
||||
if (Corpse* corpse = _player->GetCorpse())
|
||||
if (Corpse* corpse = player->GetCorpse())
|
||||
{ corpseMapId = corpse->GetMapId(); }
|
||||
|
||||
// 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
|
||||
if (!instance_map)
|
||||
{
|
||||
_player->GetSession()->SendAreaTriggerMessage("You can not enter %s while in a ghost mode",
|
||||
targetMapEntry->name[_player->GetSession()->GetSessionDbcLocale()]);
|
||||
player->GetSession()->SendAreaTriggerMessage("You can not enter %s while in a ghost mode",
|
||||
targetMapEntry->name[player->GetSession()->GetSessionDbcLocale()]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -811,20 +813,20 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
}
|
||||
|
||||
// now we can resurrect player, and then check teleport requirements
|
||||
_player->ResurrectPlayer(0.5f);
|
||||
_player->SpawnCorpseBones();
|
||||
player->ResurrectPlayer(0.5f);
|
||||
player->SpawnCorpseBones();
|
||||
}
|
||||
|
||||
uint32 miscRequirement = 0;
|
||||
AreaLockStatus lockStatus = _player->GetAreaTriggerLockStatus(at, miscRequirement);
|
||||
AreaLockStatus lockStatus = player->GetAreaTriggerLockStatus(at, miscRequirement);
|
||||
if (lockStatus != AREA_LOCKSTATUS_OK)
|
||||
{
|
||||
_player->SendTransferAbortedByLockStatus(targetMapEntry, lockStatus, miscRequirement);
|
||||
player->SendTransferAbortedByLockStatus(targetMapEntry, lockStatus, miscRequirement);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user