• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] new phaseing out duel dont' work 100%

Status
Not open for further replies.

Shaorin

Respected Member
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::playerList const& players = map->GetPlayers();
for (Map::playerList::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.
 

Rochet2

Moderator / Eluna Dev
Hmm, interesting, when SetPhaseMask seems to try to phase the pets and other summons the player has.
 

Shaorin

Respected Member
ok i see. can you help me fix it? and maybe set a 5 sec time after the duel end and the phase back? whould be really happy^^
 

Tommy

Founder
Why does everyone have to ruin the indentation? Here you go, this should restore player pet's if they have any:

Code:
#include "MapManager.h"
#include "Pet.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::PlayerList const& players = map->GetPlayers();
        for (Map::PlayerList::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);
		if (Pet* pet = firstplayer->GetPet())
		    pet->SetPhaseMask(GetPhase(firstplayer), true);
        secondplayer->SetPhaseMask(GetPhase(secondplayer), true);
		if (Pet* pet = secondplayer->GetPet())
		    pet->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();
}
 
Last edited:

Shaorin

Respected Member
thx so mutch. are to mutch of a noob in c++ to undersand on what to do^^

- - - Updated - - -

did not work, get this errors:

3> phasedueling.cpp
3>..\..\..\..\..\Users\Origami\Desktop\Ny mapp (2)\phasedueling.cpp(41): error C2027: use of undefined type 'Pet'
3> c:\trinitycore-master\src\server\game\grids\GridDefines.h(31) : see declaration of 'Pet'
3>..\..\..\..\..\Users\Origami\Desktop\Ny mapp (2)\phasedueling.cpp(41): error C2227: left of '->SetPhaseMask' must point to class/struct/union/generic type
3>..\..\..\..\..\Users\Origami\Desktop\Ny mapp (2)\phasedueling.cpp(44): error C2027: use of undefined type 'Pet'
3> c:\trinitycore-master\src\server\game\grids\GridDefines.h(31) : see declaration of 'Pet'
3>..\..\..\..\..\Users\Origami\Desktop\Ny mapp (2)\phasedueling.cpp(44): error C2227: left of '->SetPhaseMask' must point to class/struct/union/generic type
 

Rochet2

Moderator / Eluna Dev
Do you mean phasing the pet doesnt work or that phasing out of the duel leaves the pet inside the phase?
You need to add #include "Pet.h" to fix the compile errors
 

Shaorin

Respected Member
thx^^ the thing that did not work was phase the pet in. out np. but how do i add a timer on the out phaseing? i want it to be like 5 sec and then phase it back.
 
Status
Not open for further replies.
Top