Ir para conteúdo
  • Cadastre-se
  • 0

(Resolvido) Método


IronMaiden

Pergunta

Boa noite,alguém me explica porque esse método não funciona no segundo exemplo ( activeChar.isAttackingNow() )

Eu gostaria que o char não clicasse perto do próprio pé em modo de combat.No primeiro exemplo dá tudo certo sem o método, no segundo que é a mesma coisa só com o método não acontece nada.

 

 

 

if (activeChar.isOutOfControl() || dx * dx + dy * dy < 5000)

{

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

activeChar.sendMessage("You were clicking too fast.");

return;

}

 

 

 

 

if (activeChar.isAttackingNow() && (activeChar.isOutOfControl() || dx * dx + dy * dy < 75000))

{

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

activeChar.sendMessage("You were clicking too fast.");

return;

}

 

O código completo;

 

 

 

* This program is free software: you can redistribute it and/or modify it under

* the terms of the GNU General Public License as published by the Free Software

* Foundation, either version 3 of the License, or (at your option) any later

* version.

*

* This program is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more

* details.

*

* You should have received a copy of the GNU General Public License along with

* this program. If not, see <

O conteúdo está oculto, favor efetuar login ou se cadastrar!

*/

package com.l2jfrozen.gameserver.network.clientpackets;

 

import java.nio.BufferUnderflowException;

 

import com.l2jfrozen.Config;

import com.l2jfrozen.gameserver.ai.CtrlIntention;

import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;

import com.l2jfrozen.gameserver.model.actor.position.L2CharPosition;

import com.l2jfrozen.gameserver.network.SystemMessageId;

import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;

import com.l2jfrozen.gameserver.network.serverpackets.StopMove;

import com.l2jfrozen.gameserver.thread.TaskPriority;

import com.l2jfrozen.gameserver.util.IllegalPlayerAction;

import com.l2jfrozen.gameserver.util.Util;

import com.l2jfrozen.gameserver.model.L2Character;

 

@SuppressWarnings("unused")

public class MoveBackwardToLocation extends L2GameClientPacket

{

private int _targetX, _targetY, _targetZ, _originX, _originY, _originZ, _moveMovement;

private int _curX, _curY, _curZ; // for geodata

 

public TaskPriority getPriority()

{

return TaskPriority.PR_HIGH;

}

 

@Override

protected void readImpl()

{

_targetX = readD();

_targetY = readD();

_targetZ = readD();

_originX = readD();

_originY = readD();

_originZ = readD();

 

try

{

_moveMovement = readD(); // is 0 if cursor keys are used 1 if mouse is used

}

catch (BufferUnderflowException e)

{

if (Config.ENABLE_ALL_EXCEPTIONS)

e.printStackTrace();

 

// Ignore for now

if (Config.L2WALKER_PROTEC)

{

L2PcInstance activeChar = getClient().getActiveChar();

activeChar.sendPacket(SystemMessageId.HACKING_TOOL);

Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " trying to use L2Walker!", IllegalPlayerAction.PUNISH_KICK);

}

}

}

 

@Override

protected void runImpl()

{

L2PcInstance activeChar = getClient().getActiveChar();

 

if(activeChar == null)

return;

 

// Move flood protection

if (!getClient().getFloodProtectors().getMoveAction().tryPerformAction("MoveBackwardToLocation"))

{

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

return;

}

 

if(activeChar.getPrivateStoreType() != 0 ){

getClient().sendPacket(ActionFailed.STATIC_PACKET); // movements prohibited when in store or atk

return;

}

 

 

if (_targetX == _originX && _targetY == _originY && _targetZ == _originZ)

{

activeChar.sendPacket(new StopMove(activeChar));

return;

}

 

// Correcting targetZ from floor level to head level

_targetZ += activeChar.getTemplate().collisionHeight;

 

_curX = activeChar.getX();

_curY = activeChar.getY();

_curZ = activeChar.getZ();

 

if (activeChar.getTeleMode() > 0)

{

if (activeChar.getTeleMode() == 1)

activeChar.setTeleMode(0);

 

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

activeChar.teleToLocation(_targetX, _targetY, _targetZ, false);

return;

}

 

if (_moveMovement == 0 && !Config.ALLOW_USE_CURSOR_FOR_WALK)

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

else

{

double dx = _targetX - _curX;

double dy = _targetY - _curY;

 

 

// Can't move if character is confused, or trying to move a huge distance

if (activeChar.isOutOfControl() || dx * dx + dy * dy > 98010000) // 9900*9900

{

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

return;

}

// Can't move if character is confused, or trying to move a huge distance

 

if (activeChar.isAttackingNow() && (activeChar.isOutOfControl() || dx * dx + dy * dy < 75000))

{

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

activeChar.sendMessage("You were clicking too fast.");

return;

}

if (activeChar.isOutOfControl() || dx * dx + dy * dy < 5000)

{

activeChar.sendPacket(ActionFailed.STATIC_PACKET);

activeChar.sendMessage("You were clicking too fast.");

return;

}

 

activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(_targetX, _targetY, _targetZ, 0));

}

}

 

@Override

public String getType()

{

return "[C] 01 MoveBackwardToLoc";

}

}

 

 

VSSjA.png
Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts recomendados

Até agora não há respostas para essa pergunta

Visitante
Este tópico está impedido de receber novos posts.



×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.