Core/Dungeon Finder: Simplify Spell Luck of the draw code
Core/Dungeon Finder: Partial recode of "group list" using existing Lfg functions
This commit is contained in:
1 parent
ffb4c63fe3
commit
f753c989f2
5 files changed
+77
-55
No files matched your search
@@ -33,7 +33,7 @@
|
||||
#include "ace/INET_Addr.h"
|
||||
#include "Player.h"
|
||||
#include "Pet.h"
|
||||
#include "LFG.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "GroupMgr.h"
|
||||
|
||||
class misc_commandscript : public CommandScript
|
||||
@@ -2834,41 +2834,40 @@ public:
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"));
|
||||
Group::MemberSlotList const& members = groupTarget->GetMemberSlots();
|
||||
Group::MemberSlotList::const_iterator itr;
|
||||
for (itr = members.begin(); itr != members.end(); ++itr)
|
||||
for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
|
||||
{
|
||||
std::ostringstream flags, roles;
|
||||
if ((*itr).flags & MEMBER_FLAG_ASSISTANT)
|
||||
flags << "Assistant ";
|
||||
if ((*itr).flags & MEMBER_FLAG_MAINTANK)
|
||||
flags << "MainTank ";
|
||||
if ((*itr).flags & MEMBER_FLAG_MAINASSIST)
|
||||
flags << "MainAssist ";
|
||||
Group::MemberSlot const& slot = *itr;
|
||||
|
||||
if ((*itr).roles & PLAYER_ROLE_LEADER)
|
||||
roles << "Leader ";
|
||||
if ((*itr).roles & PLAYER_ROLE_TANK)
|
||||
roles << "Tank ";
|
||||
if ((*itr).roles & PLAYER_ROLE_HEALER)
|
||||
roles << "Healer ";
|
||||
if ((*itr).roles & PLAYER_ROLE_DAMAGE)
|
||||
roles << "Damage ";
|
||||
std::string flags;
|
||||
if (slot.flags & MEMBER_FLAG_ASSISTANT)
|
||||
flags = "Assistant";
|
||||
|
||||
if (slot.flags & MEMBER_FLAG_MAINTANK)
|
||||
{
|
||||
if (!flags.empty())
|
||||
flags.append(", ");
|
||||
flags.append("MainTank");
|
||||
}
|
||||
|
||||
if (slot.flags & MEMBER_FLAG_MAINASSIST)
|
||||
{
|
||||
if (!flags.empty())
|
||||
flags.append(", ");
|
||||
flags.append("MainAssist");
|
||||
}
|
||||
|
||||
if (flags.empty())
|
||||
flags = "None";
|
||||
|
||||
Player* p = ObjectAccessor::FindPlayer((*itr).guid);
|
||||
const char* onlineState = (p && p->IsInWorld()) ? "online" : "offline";
|
||||
|
||||
std::string flagsStr = (flags.str().empty()) ? "None" : flags.str();
|
||||
std::string rolesStr = (roles.str().empty()) ? "None" : roles.str();
|
||||
|
||||
handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, (*itr).name.c_str(), onlineState, GUID_LOPART((*itr).guid), flagsStr.c_str(), rolesStr.c_str());
|
||||
handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState,
|
||||
GUID_LOPART(slot.guid), flags.c_str(), LFGMgr::GetRolesString(slot.roles).c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, nameTarget.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1715,10 +1715,29 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader
|
||||
class spell_gen_luck_of_the_draw_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_gen_luck_of_the_draw_AuraScript);
|
||||
Map const* map;
|
||||
Difficulty difficulty;
|
||||
|
||||
bool Load()
|
||||
{
|
||||
return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER;
|
||||
Player* owner = GetUnitOwner()->ToPlayer();
|
||||
if (!owner)
|
||||
return false;
|
||||
|
||||
Group* group = owner->GetGroup();
|
||||
if (!group || group->isLFGGroup())
|
||||
return false;
|
||||
|
||||
if (!sLFGMgr->inRandomLfgDungeon(owner->GetGUID()))
|
||||
return false;
|
||||
|
||||
map = owner->GetMap();
|
||||
difficulty = owner->GetMap()->GetDifficulty();
|
||||
|
||||
if (!sLFGMgr->inLfgDungeonMap(owner->GetGUID(), map->GetId(), difficulty))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// cheap hax to make it have update calls
|
||||
@@ -1730,30 +1749,9 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader
|
||||
|
||||
void Update(AuraEffect* /*effect*/)
|
||||
{
|
||||
if (Player* owner = GetUnitOwner()->ToPlayer())
|
||||
{
|
||||
const LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(owner->GetGUID());
|
||||
LfgDungeonSet::const_iterator itr = dungeons.begin();
|
||||
|
||||
if (itr == dungeons.end())
|
||||
{
|
||||
Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LFGDungeonData const* randomDungeon = sLFGMgr->GetLFGDungeon(*itr);
|
||||
if (Group* group = owner->GetGroup())
|
||||
if (Map const* map = owner->GetMap())
|
||||
if (group->isLFGGroup())
|
||||
if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true))
|
||||
if (LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(dungeonId))
|
||||
if (uint32(dungeon->map) == map->GetId() && dungeon->difficulty == map->GetDifficulty())
|
||||
if (randomDungeon && randomDungeon->type == LFG_TYPE_RANDOM)
|
||||
return; // in correct dungeon
|
||||
|
||||
Map const* currentMap = GetUnitOwner()->ToPlayer()->GetMap();
|
||||
if (currentMap != map || currentMap->GetDifficulty() != difficulty)
|
||||
Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
|
||||
Reference in new issue
Block a user