Jump to content

[Tutorial]Nova função que define se o pet segue ou não o jogador


Luffy
 Share

Recommended Posts

Olá pessoal, vim lhes trazer esta função que eu mesmo fiz. Ela serve pra definir se o pet segue ou não o jogador. Já aviso que só entendo C++  e lua de forma bem superficial. Tenho certeza que alguém com mais conhecimento pode melhorar a função.

Vamos lá

vão em game/scr

abram PetSystem.cpp

e adicionem isto:(é só seguir o padrão)

Spoiler

bool CPetActor::PetNoFollow()
{
    if    (false == PetNoFollowing)
    {
        PetNoFollowing = true;
        return true;
    }

    if (true == PetNoFollowing)
    {
        PetNoFollowing = false;
        return true;
    }
}

void CPetSystem::PetAlFollow()
{
    for (auto iter = m_petActorMap.begin(); iter != m_petActorMap.end(); ++iter)
    {
        CPetActor* petActor = iter->second;
        if (0 != petActor)
        {
            if (petActor->IsSummoned())
            {
                petActor->PetNoFollow();
            }
        }
    }
    return;
}

depois procurem por

 if (fDist >= START_FOLLOW_DISTANCE)

e editem assim:

Spoiler

if (fDist >= START_FOLLOW_DISTANCE && false == PetNoFollowing)

Procurem por

 m_pkChar->Show (m_pkOwner->GetMapIndex(), x, y, z);

e coloquem isto em baixo:

PetNoFollowing = false;

Depois abram PetSystem.h

procurem por void ClearBuff();

coloquem isto em baixo:

bool PetNoFollowing;

procurem por 

LPCHARACTER m_pkChar;
    LPCHARACTER m_pkOwner;

coloquem isto em baixo:

bool PetNoFollow();

procurem por

 void RefreshBuff();

coloquem isso em baixo:

void PetAlFollow();

Depois abrem queslua_pet.cpp

adicionem isto:(sigam o padrão)

Spoiler

    int pet_is_follow (lua_State* L)
    {
        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        CPetSystem* petSystem = ch->GetPetSystem();

        if (0 == petSystem)
        {
            return 0;
        }
        petSystem->PetAlFollow();
        return 1;
    }

depois procurem por { "count_summoned",    pet_count_summoned    },

e adicionem isto em baixo:

{ "is_follow",        pet_is_follow        },

Compilem.

vão nas suas serverfiles entrem na pasta quest abram o quest_functions e adicionem pet.is_follow

FIM

Exemplo de quest:

Spoiler

quest pet_system begin
    state start begin
        when idpet.click begin   
            if pet.is_mine() == true then
                   pet.is_follow()
               end
        end
    end
end

 

Edited by Luffy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...