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

Phased duel (pets work)

callmephil

Respected Member
Rethink your logic.

Rethink yours, because i'm using OnduelRequest and i don't have the countdown problem.

PS : I'm working on trap issues. as i know trap are spawning creatures when they are opened and thoses creatures aren't re-phased so we need to find how to phases them.
 

pinkyflip

Banned
not working

this don't work on TC with boost.


Code:
		GameObject* go = map->GetGameObject(firstplayer->GetUInt64Value(PLAYER_DUEL_ARBITER));

error is 1 no suitable constructor exists to convert from "uint64" to "ObjectGuid" c:\Users\James\Desktop\server\TrinityCore\src\server\scripts\Custom\Phaseduels.cpp 156 39 scripts

any fix for this too work with boost?
 
Last edited:

Rochet2

Moderator / Eluna Dev
this don't work on TC with boost.


Code:
		GameObject* go = map->GetGameObject(firstplayer->GetUInt64Value(PLAYER_DUEL_ARBITER));

error is 1 no suitable constructor exists to convert from "uint64" to "ObjectGuid" c:\Users\James\Desktop\server\TrinityCore\src\server\scripts\Custom\Phaseduels.cpp 156 39 scripts

any fix for this too work with boost?

Its not about boost, its about ObjectGuid change.
Try using ObjectGuid(firstplayer->GetUInt64Value(PLAYER_DUEL_ARBITER))
 

Estorn

Respected Member
Error 1 error C2664: 'GameObject *Map::GetGameObject(ObjectGuid)' : cannot convert argument 1 from 'uint64' to 'ObjectGuid' C:\Users\devel_000\Desktop\\src\server\scripts\Custom\DuelPhase.cpp 28 1 scripts
 

Rochet2

Moderator / Eluna Dev
Error 1 error C2664: 'GameObject *Map::GetGameObject(ObjectGuid)' : cannot convert argument 1 from 'uint64' to 'ObjectGuid' C:\Users\devel_000\Desktop\\src\server\scripts\Custom\DuelPhase.cpp 28 1 scripts

read the thread.
 

Wolord

Exalted Member
It should be like this?
Code:
/*
Credits:
Rochet2
Tommy

There were few more, but couldnt find them

Release:
http://emudevs.com/showthread.php/3413-Phased-duel-(pets-work)?p=24109
Original source:
http://emudevs.com/showthread.php/2282-phase-out-dueling-error?p=15483&viewfull=1#post15483
*/

#include "ScriptPCH.h"

class Phased_duel : public PlayerScript
{
public:
    Phased_duel(): PlayerScript("Phased_duel") { }

    void OnDuelStart(Player* firstplayer, Player* secondplayer) override
    {
        Map* map = firstplayer->GetMap();
        if (map->IsDungeon())
            return;

        // Duel flag is used as duel center point
        GameObject* go = map->GetGameObject(ObjectGuid(firstplayer->GetUInt64Value(PLAYER_DUEL_ARBITER)));
        if (!go)
            return;

        // Get players from 100 yard radius ( duel radius is 40-50 yd )
        std::list<Player*> playerList;
        Trinity::AnyPlayerInObjectRangeCheck checker(go, 100.0f);
        Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(go, playerList, checker);
        go->VisitNearbyWorldObject(100.0f, searcher);

        // insert players' phases to used phases, ignore GMs
        uint32 usedPhases = 0;
        if (!playerList.empty())
            for (std::list<Player*>::const_iterator it = playerList.begin(); it != playerList.end(); ++it)
                if (!(*it)->IsGameMaster())
                    usedPhases |= (*it)->GetPhaseMask();

        // loop all unique phases
        for (uint32 phase = 2; phase <= ULONG_MAX / 2; phase *= 2)
        {
            // If phase in use, skip
            if (usedPhases & phase)
                continue;

            // Phase players & pets, dont update visibility yet
            firstplayer->SetPhaseMask(phase, false);
            secondplayer->SetPhaseMask(phase, false);
            // Phase duel flag
            go->SetPhaseMask(phase, true);
            // Update visibility here so pets will be phased and wont despawn
            firstplayer->UpdateObjectVisibility();
            secondplayer->UpdateObjectVisibility();
            return;
        }

        // Couldnt find free unique phase
        firstplayer->GetSession()->SendNotification("There are no free phases");
        secondplayer->GetSession()->SendNotification("There are no free phases");
    }

    // Restore phases
    void OnDuelEnd(Player* firstplayer, Player* secondplayer, DuelCompleteType type) override
    {
        // Phase players, dont update visibility yet
        firstplayer->SetPhaseMask(GetNormalPhase(firstplayer), false);
        secondplayer->SetPhaseMask(GetNormalPhase(secondplayer), false);
        // Update visibility here so pets will be phased and wont despawn
        firstplayer->UpdateObjectVisibility();
        secondplayer->UpdateObjectVisibility();
    }

    // Attempt in storing the player phase with spell phases included.
    uint32 GetNormalPhase(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_Phased_duel()
{
    new Phased_duel();
}

- - - Updated - - -

I compiled it like this and I hadn't any problems and errors.:argue:
 

Optimus

Emulation Addict
Hey gentlemans,
is it possible for you to update this cool script for: TrinityCore rev. 431da2ffc984+ 2016-03-05 01:26:26 +0000 (3.3.5 branch) (Unix, Release) - TDB 335.60.

It will be so good if you can do that for me and the community.

Thanks in advance!
 
Top