Ir para conteúdo
  • 0
CoehManeh

Programação Summon/Pet passar por monstros

Pergunta

CoehManeh    4
CoehManeh

Olá pessoal,

Eu consegui adaptar o Summon/Pet para entrar no PZ, passar por dentro dos jogadores e não ser atacado. Porém, estou precisando agora que ele passe também por dentro dos monstros. A ideia do summon será apenas um suporte (como os do Naruto), ele não atrapalhará em nada, apenas dará alguns bônus como life, mana e outros para o dono.

Para uma possível ajuda nessa adaptação, vou mostrar baixo aonde editei o código para que ele possa passar por dentro do player (arquivo player.cpp) alterei as linhas onde têm bool Player::canWalkthrough(const Creature* creature) const até o fechamento dela e bool Player::canWalkthroughEx(const Creature* creature) const também até o fechamento dela por todo esse código abaixo:

bool Player::canWalkthrough(const Creature* creature) const
{
    if (group->access || creature->isInGhostMode()) {
        return true;
    }

    if (creature->isSummon() && creature->getMaster()->getPlayer()) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Tile* playerTile = player->getTile();
    if (!playerTile || (!playerTile->hasFlag(TILESTATE_PROTECTIONZONE) && player->getLevel() > static_cast<uint32_t>(g_config.getNumber(ConfigManager::PROTECTION_LEVEL)))) {
        return false;
    }

    const Item* playerTileGround = playerTile->getGround();
    if (!playerTileGround || !playerTileGround->hasWalkStack()) {
        return false;
    }

    Player* thisPlayer = const_cast<Player*>(this);
    if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
        thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
        return false;
    }

    if (creature->getPosition() != lastWalkthroughPosition) {
        thisPlayer->setLastWalkthroughPosition(creature->getPosition());
        return false;
    }

    thisPlayer->setLastWalkthroughPosition(creature->getPosition());
    return true;
}

bool Player::canWalkthroughEx(const Creature* creature) const
{
    if (group->access) {
        return true;
    }

    if (creature->isSummon() && creature->getMaster()->getPlayer()) {
        return true;
    }

    const Player* player = creature->getPlayer();
    if (!player) {
        return false;
    }

    const Tile* playerTile = player->getTile();
    return playerTile && (playerTile->hasFlag(TILESTATE_PROTECTIONZONE) || player->getLevel() <= static_cast<uint32_t>(g_config.getNumber(ConfigManager::PROTECTION_LEVEL)));
}

E também adicionei esse código g_game.updateCreatureWalkthrough(creature); acima do g_game.updateCreatureType(creature); que está no arquivo luascript.cpp

Pronto, com isso ele passa a andar por dentro dos jogadores.

-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-

APROVEITANDO o mesmo post, se alguém souber como faz para Summonar DENTRO DO PZ, por favor.

Eu adaptei para ele entrar no PZ quando o jogador entrar, mas dentro do PZ não da pra sumonar caso o Pet/Summon não esteja sumonado. Vou mostrar aonde editei os códigos aqui abaixo pra facilitar o suporte.

Dentro de ReturnValue Tile::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t flags, Creature*) const no arquivo tile.cpp procurei a linha if (hasFlag(TILESTATE_PROTECTIONZONE | TILESTATE_FLOORCHANGE | TILESTATE_TELEPORT)) { e adicionei o código seguinte logo a baixo dele.

				// INÍCIO SUMMON ENTRAR NO PZ
				if (creature->isSummon())	{
					if (hasFlag(TILESTATE_BLOCKSOLID)) {
						return RETURNVALUE_NOTPOSSIBLE;
					}
					return RETURNVALUE_NOERROR;
				}
				// FIM SUMMON ENTRAR NO PZ

Pronto, agora ele já entra no PZ com o player.

-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-

E pra finalizar, o código que usei pra sumonar (scripts do movements): (obs.: como não estou conseguindo fazer com que sumone-o dentro do PZ, eu adaptei um sistema para avisar que dentro do PZ não da pra sumonar, porém não é isso que eu quero, coloquei provisoriamente).

local cfg = {
    monster = "Rat"
}

function onDeEquip(cid, item, slot)
	if #getCreatureSummons(cid) >= 1 then
		local pet = getCreatureSummons(cid)
		for _, k in ipairs(pet) do
			doSendMagicEffect(getThingPos(k), 13)
			doRemoveCreature(k)
		return true
		end
	end
	return true
end

function onEquip(cid, item, slot)
	if getTilePzInfo(getCreaturePosition(cid)) then
		doPlayerSendCancel(cid, "This summon is not permitted in a protection zone.")
	else
		if #getCreatureSummons(cid) == 0 then
			local monster = doSummonCreature(cfg.monster, getThingPos(cid))
	        doConvinceCreature(cid, monster)
			doSendMagicEffect(getThingPos(cid), 13)
		end
	end
	return true
end

-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-

Para o Pet/Summon não ser atacado eu simplesmente marquei como "0" dentro do código do próprio monstro <flag attackable="0"/>

 

DESDE JÁ OBRIGADO !

Editado por CoehManeh

Compartilhar este post


Link para o post
Compartilhar em outros sites

2 respostass a esta questão

Recommended Posts

  • 0
CoehManeh    4
CoehManeh

Olá,

Problema resolvido por mim mesmo.

Basta alterar essa parte na source:

            if (monster->canPushCreatures() && !monster->isSummon()) {
                if (creatures) {
                    for (Creature* tileCreature : *creatures) {
                        if (tileCreature->getPlayer() && tileCreature->getPlayer()->isInGhostMode()) {
                            continue;
                        }
                        const Monster* creatureMonster = tileCreature->getMonster();
                        if (!creatureMonster || (!tileCreature->isPushable() && !creatureMonster->isSummon())) {
                            return RETURNVALUE_NOTPOSSIBLE;
                        }
                    }
                }
            } else if (creatures && !creatures->empty()) {
                for (const Creature* tileCreature : *creatures) {
                    if (tileCreature->isInGhostMode() || tileCreature->isSummon()) {
                        continue;
                    }
 
                    return RETURNVALUE_NOTENOUGHROOM;
                }
            }

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Majesty    1755
Majesty

O autor do tópico resolveu a questão por conta própria e postou a solução. Este tópico está fechado agora. Se você tiver outras perguntas, crie um novo tópico.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×