mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Core/Dungeon Finder: Use scripts to interact between groups and LFG
--HG-- branch : trunk
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "MapInstanced.h"
|
||||
#include "Util.h"
|
||||
#include "LFGMgr.h"
|
||||
|
||||
Group::Group()
|
||||
{
|
||||
@@ -307,9 +306,6 @@ Player* Group::GetInvited(const std::string& name) const
|
||||
|
||||
bool Group::AddMember(const uint64 &guid, const char* name)
|
||||
{
|
||||
if (isLfgQueued())
|
||||
sLFGMgr.Leave(NULL, this);
|
||||
|
||||
if (!_addMember(guid, name))
|
||||
return false;
|
||||
|
||||
@@ -319,8 +315,6 @@ bool Group::AddMember(const uint64 &guid, const char* name)
|
||||
Player *player = sObjectMgr.GetPlayer(guid);
|
||||
if (player)
|
||||
{
|
||||
if (player->isUsingLfg())
|
||||
sLFGMgr.Leave(player);
|
||||
if (!IsLeader(player->GetGUID()) && !isBGGroup())
|
||||
{
|
||||
// reset the new member's instances, unless he is currently in one of them
|
||||
@@ -360,11 +354,6 @@ uint32 Group::RemoveMember(const uint64 &guid, const RemoveMethod &method)
|
||||
{
|
||||
BroadcastGroupUpdate();
|
||||
|
||||
if (isLfgQueued())
|
||||
sLFGMgr.Leave(NULL, this);
|
||||
else if (isLFGGroup() && !isLfgDungeonComplete())
|
||||
sLFGMgr.OfferContinue(this);
|
||||
|
||||
sScriptMgr.OnGroupRemoveMember(this, guid, method);
|
||||
|
||||
// remove member and change leader (if need) only if strong more 2 members _before_ member remove
|
||||
@@ -387,15 +376,9 @@ uint32 Group::RemoveMember(const uint64 &guid, const RemoveMethod &method)
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
|
||||
if (isLFGGroup() && player->GetMap()->IsDungeon())
|
||||
player->TeleportToBGEntryPoint();
|
||||
|
||||
//we already removed player from group and in player->GetGroup() is his original group!
|
||||
if (Group* group = player->GetGroup())
|
||||
{
|
||||
group->SendUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
data.Initialize(SMSG_GROUP_LIST, 1+1+1+1+8+4+4+8);
|
||||
@@ -461,11 +444,6 @@ void Group::Disband(bool hideDestroy /* = false */)
|
||||
player->SetOriginalGroup(NULL);
|
||||
else
|
||||
player->SetGroup(NULL);
|
||||
|
||||
if (isLFGGroup() && player->GetMap()->IsDungeon())
|
||||
player->TeleportToBGEntryPoint();
|
||||
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
|
||||
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
|
||||
}
|
||||
|
||||
// quest related GO state dependent from raid membership
|
||||
@@ -1298,8 +1276,6 @@ bool Group::_removeMember(const uint64 &guid)
|
||||
player->SetOriginalGroup(NULL);
|
||||
else
|
||||
player->SetGroup(NULL);
|
||||
|
||||
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ void AddSC_npc_innkeeper();
|
||||
void AddSC_npcs_special();
|
||||
void AddSC_npc_taxi();
|
||||
void AddSC_achievement_scripts();
|
||||
void AddSC_dungeon_finder();
|
||||
|
||||
//eastern kingdoms
|
||||
void AddSC_alterac_valley(); //Alterac Valley
|
||||
@@ -619,6 +620,7 @@ void AddWorldScripts()
|
||||
AddSC_npc_taxi();
|
||||
AddSC_achievement_scripts();
|
||||
AddSC_chat_log();
|
||||
AddSC_dungeon_finder();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -186,8 +186,6 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recv_data)
|
||||
data << uint32(0); // unk
|
||||
player->GetSession()->SendPacket(&data);
|
||||
|
||||
SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK);
|
||||
}
|
||||
|
||||
@@ -230,14 +228,6 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket & /*recv_data*/)
|
||||
if (!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
|
||||
return;
|
||||
|
||||
SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
if (Player *plrg = itr->getSource())
|
||||
{
|
||||
plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
|
||||
}
|
||||
|
||||
group->BroadcastGroupUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "SocialMgr.h"
|
||||
#include "zlib.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "Transport.h"
|
||||
|
||||
/// WorldSession constructor
|
||||
@@ -324,11 +323,6 @@ void WorldSession::LogoutPlayer(bool Save)
|
||||
|
||||
if (_player)
|
||||
{
|
||||
sLFGMgr.Leave(_player);
|
||||
GetPlayer()->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
GetPlayer()->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
GetPlayer()->GetSession()->SendLfgUpdateSearch(false);
|
||||
|
||||
if (uint64 lguid = GetPlayer()->GetLootGUID())
|
||||
DoLootRelease(lguid);
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
set(scripts_STAT_SRCS
|
||||
${scripts_STAT_SRCS}
|
||||
World/npc_professions.cpp
|
||||
World/mob_generic_creature.cpp
|
||||
World/npc_taxi.cpp
|
||||
World/boss_lethon.cpp
|
||||
World/achievement_scripts.cpp
|
||||
World/areatrigger_scripts.cpp
|
||||
World/boss_emeriss.cpp
|
||||
World/boss_lethon.cpp
|
||||
World/boss_taerar.cpp
|
||||
World/boss_ysondre.cpp
|
||||
World/chat_log.cpp
|
||||
World/dungeon_finder.cpp
|
||||
World/go_scripts.cpp
|
||||
World/guards.cpp
|
||||
World/item_scripts.cpp
|
||||
World/boss_ysondre.cpp
|
||||
World/npcs_special.cpp
|
||||
World/chat_log.cpp
|
||||
World/boss_taerar.cpp
|
||||
World/go_scripts.cpp
|
||||
World/mob_generic_creature.cpp
|
||||
World/npc_innkeeper.cpp
|
||||
World/achievement_scripts.cpp
|
||||
World/npc_professions.cpp
|
||||
World/npc_taxi.cpp
|
||||
World/npcs_special.cpp
|
||||
)
|
||||
|
||||
message(" -> Prepared: World")
|
||||
|
||||
154
src/server/scripts/World/dungeon_finder.cpp
Normal file
154
src/server/scripts/World/dungeon_finder.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Interaction between core and LFGMgr
|
||||
*/
|
||||
|
||||
#include "ScriptPCH.h"
|
||||
#include "LFGMgr.h"
|
||||
|
||||
class DungeonFinderScript: public GroupScript, PlayerScript
|
||||
{
|
||||
public:
|
||||
DungeonFinderScript(): GroupScript("DungeonFinderScript"), PlayerScript("DungeonFinderScript") { }
|
||||
|
||||
void OnAddMember(Group* group, uint64 guid)
|
||||
{
|
||||
uint64 gguid = group->GetGUID();
|
||||
sLog.outError("OnAddMember [" UI64FMTD "]: added [" UI64FMTD "]", gguid, guid);
|
||||
if (!gguid)
|
||||
return;
|
||||
|
||||
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
if (Player *plrg = itr->getSource())
|
||||
{
|
||||
plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
|
||||
}
|
||||
}
|
||||
|
||||
if (group->isLfgQueued())
|
||||
sLFGMgr.Leave(NULL, group);
|
||||
|
||||
Player *plr = sObjectMgr.GetPlayer(guid);
|
||||
if (plr && plr->isUsingLfg())
|
||||
sLFGMgr.Leave(plr);
|
||||
}
|
||||
|
||||
void OnRemoveMember(Group* group, uint64 guid, RemoveMethod& method)
|
||||
{
|
||||
uint64 gguid = group->GetGUID();
|
||||
sLog.outError("OnRemoveMember [" UI64FMTD "]: remove [" UI64FMTD "] Method: %d", gguid, guid, method);
|
||||
if (!gguid)
|
||||
return;
|
||||
|
||||
if (group->isLfgQueued())
|
||||
{
|
||||
// TODO - Do not remove, just remove the one leaving and rejoin queue with all other data
|
||||
sLFGMgr.Leave(NULL, group);
|
||||
}
|
||||
|
||||
if (!group->isLFGGroup())
|
||||
return;
|
||||
|
||||
if (!group->isLfgDungeonComplete()) // Need more players to finish the dungeon
|
||||
sLFGMgr.OfferContinue(group);
|
||||
|
||||
if (method == GROUP_REMOVEMETHOD_KICK) // Player have been kicked
|
||||
{
|
||||
// TODO - Update internal kick cooldown
|
||||
}
|
||||
else
|
||||
{
|
||||
// Deserter flag
|
||||
}
|
||||
|
||||
if (Player *plr = sObjectMgr.GetPlayer(guid))
|
||||
{
|
||||
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
|
||||
if (plr->GetMap()->IsDungeon()) // Teleport player out the dungeon
|
||||
sLFGMgr.TeleportPlayer(plr, true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisband(Group* group)
|
||||
{
|
||||
uint64 gguid = group->GetGUID();
|
||||
sLog.outError("OnDisband [" UI64FMTD "]", gguid);
|
||||
if (!gguid)
|
||||
return;
|
||||
|
||||
if (group->isLfgQueued())
|
||||
sLFGMgr.Leave(NULL, group);
|
||||
|
||||
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
if (Player *plrg = itr->getSource())
|
||||
{
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
|
||||
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
|
||||
if (plrg->GetMap()->IsDungeon()) // Teleport player out the dungeon
|
||||
sLFGMgr.TeleportPlayer(plrg, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid)
|
||||
{
|
||||
uint64 gguid = group->GetGUID();
|
||||
sLog.outError("OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid);
|
||||
if (!gguid)
|
||||
return;
|
||||
|
||||
Player *plr = sObjectMgr.GetPlayer(newLeaderGuid);
|
||||
if (plr)
|
||||
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
|
||||
|
||||
plr = sObjectMgr.GetPlayer(oldLeaderGuid);
|
||||
if (plr)
|
||||
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
|
||||
}
|
||||
|
||||
void OnInviteMember(Group* group, uint64 guid)
|
||||
{
|
||||
uint64 gguid = group->GetGUID();
|
||||
sLog.outError("OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, group->GetLeaderGUID());
|
||||
if (!gguid)
|
||||
return;
|
||||
|
||||
sLFGMgr.Leave(NULL, group);
|
||||
}
|
||||
|
||||
void OnLevelChanged(Player* /*player*/, uint8 /*newLevel*/)
|
||||
{
|
||||
}
|
||||
|
||||
void OnLogout(Player* player)
|
||||
{
|
||||
sLFGMgr.Leave(player);
|
||||
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
player->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
|
||||
player->GetSession()->SendLfgUpdateSearch(false);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_dungeon_finder()
|
||||
{
|
||||
new DungeonFinderScript();
|
||||
}
|
||||
Reference in New Issue
Block a user