mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
New player method unbind all instances
This commit is contained in:
@@ -706,6 +706,7 @@ ElunaRegister<Player> PlayerMethods[] =
|
||||
{ "LeaveBattleground", &LuaPlayer::LeaveBattleground }, // :LeaveBattleground([teleToEntryPoint]) - The player leaves the battleground
|
||||
// {"BindToInstance", &LuaPlayer::BindToInstance}, // :BindToInstance() - Binds the player to the current instance
|
||||
{ "UnbindInstance", &LuaPlayer::UnbindInstance }, // :UnbindInstance(map, difficulty) - Unbinds the player from an instance
|
||||
{ "UnbindAllInstances", &LuaPlayer::UnbindAllInstances }, // :UnbindAllInstances() - Unbinds the player from all instances
|
||||
{ "RemoveFromBattlegroundRaid", &LuaPlayer::RemoveFromBattlegroundRaid }, // :RemoveFromBattlegroundRaid() - Removes the player from a battleground or battlefield raid
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
{ "ResetAchievements", &LuaPlayer::ResetAchievements }, // :ResetAchievements() - Resets player<65>s achievements
|
||||
|
||||
@@ -2174,11 +2174,19 @@ namespace LuaPlayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unbinds the [Player] from his instances except the one he currently is in.
|
||||
*
|
||||
* Difficulty is not used on classic.
|
||||
*
|
||||
* @param uint32 map = true
|
||||
* @param uint32 difficulty = 0
|
||||
*/
|
||||
int UnbindInstance(Eluna* /*E*/, lua_State* L, Player* player)
|
||||
{
|
||||
uint32 map = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
#ifndef CLASSIC
|
||||
uint32 difficulty = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
uint32 difficulty = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
if (difficulty < MAX_DIFFICULTY)
|
||||
player->UnbindInstance(map, (Difficulty)difficulty);
|
||||
@@ -2188,6 +2196,36 @@ namespace LuaPlayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unbinds the [Player] from his instances except the one he currently is in.
|
||||
*/
|
||||
int UnbindAllInstances(Eluna* /*E*/, lua_State* L, Player* player)
|
||||
{
|
||||
#ifdef CLASSIC
|
||||
Player::BoundInstancesMap& binds = player->GetBoundInstances();
|
||||
for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();)
|
||||
{
|
||||
if (itr->first != player->GetMapId())
|
||||
player->UnbindInstance(itr);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
#else
|
||||
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
|
||||
{
|
||||
Player::BoundInstancesMap& binds = player->GetBoundInstances(Difficulty(i));
|
||||
for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();)
|
||||
{
|
||||
if (itr->first != player->GetMapId())
|
||||
player->UnbindInstance(itr, Difficulty(i));
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the [Player] to leave a [BattleGround]
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user