hi all i get help before whit me duel phaseing and i have find one more error. the errir us this that pets and not whit out, they stay in the other phase: here is the script:
---------------------------------
#include "ScriptPCH.h"
#include "MapManager.h"
class PhasedDueling : public PlayerScript
{
public:
PhasedDueling() : PlayerScript("PhasedDueling") { }
void OnDuelStart(Player* firstplayer, Player* secondplayer)
{
Map* map = firstplayer->GetMap();
uint32 usedPhases = 0; // used phases
Map:layerList const& players = map->GetPlayers();
for (Map:layerList::const_iterator iter = players.begin(); iter != players.end(); ++iter)
{
Player* check = iter->GetSource();
if (!check || !check->GetSession())
continue;
usedPhases |= check->GetPhaseMask(); // insert player's phases to used phases
}
for (uint32 phase = 2; phase <= ULONG_MAX/2; phase *= 2) // loop all unique phases
{
if (usedPhases & phase) // If phase in use
continue;
firstplayer->SetPhaseMask(phase, true);
secondplayer->SetPhaseMask(phase, true);
if (GameObject* go = map->GetGameObject(firstplayer->GetUInt64Value(PLAYER_DUEL_ARBITER)))
go->SetPhaseMask(phase, true);
return;
}
// Could not phase players
}
// Restore phases
void OnDuelEnd(Player* firstplayer, Player* secondplayer, DuelCompleteType type)
{
firstplayer->SetPhaseMask(GetPhase(firstplayer), true);
secondplayer->SetPhaseMask(GetPhase(secondplayer), true);
}
// Attempt in storing the player phase with spell phases included.
uint32 GetPhase(Player* player) const
{
if (player->IsGameMaster())
return uint32(PHASEMASK_ANYWHERE);
// GetPhaseMaskForSpawn copypaste
uint32 phase = PHASEMASK_NORMAL;
Player::AuraEffectList const& phases = player->GetAuraEffectsByType(SPELL_AURA_PHASE);
if (!phases.empty())
phase = phases.front()->GetMiscValue();
if (uint32 n_phase = phase & ~PHASEMASK_NORMAL)
return n_phase;
return PHASEMASK_NORMAL;
}
};
void AddSC_PhasedDueling()
{
new PhasedDueling();
}
------------------------------------------------
thx for you help.
---------------------------------
#include "ScriptPCH.h"
#include "MapManager.h"
class PhasedDueling : public PlayerScript
{
public:
PhasedDueling() : PlayerScript("PhasedDueling") { }
void OnDuelStart(Player* firstplayer, Player* secondplayer)
{
Map* map = firstplayer->GetMap();
uint32 usedPhases = 0; // used phases
Map:layerList const& players = map->GetPlayers();
for (Map:layerList::const_iterator iter = players.begin(); iter != players.end(); ++iter)
{
Player* check = iter->GetSource();
if (!check || !check->GetSession())
continue;
usedPhases |= check->GetPhaseMask(); // insert player's phases to used phases
}
for (uint32 phase = 2; phase <= ULONG_MAX/2; phase *= 2) // loop all unique phases
{
if (usedPhases & phase) // If phase in use
continue;
firstplayer->SetPhaseMask(phase, true);
secondplayer->SetPhaseMask(phase, true);
if (GameObject* go = map->GetGameObject(firstplayer->GetUInt64Value(PLAYER_DUEL_ARBITER)))
go->SetPhaseMask(phase, true);
return;
}
// Could not phase players
}
// Restore phases
void OnDuelEnd(Player* firstplayer, Player* secondplayer, DuelCompleteType type)
{
firstplayer->SetPhaseMask(GetPhase(firstplayer), true);
secondplayer->SetPhaseMask(GetPhase(secondplayer), true);
}
// Attempt in storing the player phase with spell phases included.
uint32 GetPhase(Player* player) const
{
if (player->IsGameMaster())
return uint32(PHASEMASK_ANYWHERE);
// GetPhaseMaskForSpawn copypaste
uint32 phase = PHASEMASK_NORMAL;
Player::AuraEffectList const& phases = player->GetAuraEffectsByType(SPELL_AURA_PHASE);
if (!phases.empty())
phase = phases.front()->GetMiscValue();
if (uint32 n_phase = phase & ~PHASEMASK_NORMAL)
return n_phase;
return PHASEMASK_NORMAL;
}
};
void AddSC_PhasedDueling()
{
new PhasedDueling();
}
------------------------------------------------
thx for you help.