/* * 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 <http://www.gnu.org/licenses/>. */ package silentium.gameserver.network.clientpackets; import silentium.gameserver.model.L2Object; import silentium.gameserver.model.L2World; import silentium.gameserver.model.actor.L2Character; import silentium.gameserver.model.actor.instance.L2PcInstance; import silentium.gameserver.network.SystemMessageId; import silentium.gameserver.network.serverpackets.ActionFailed; public final class Action extends L2GameClientPacket { // cddddc private int _objectId; private int _originX, _originY, _originZ; private int _actionId; @Override protected void readImpl() { _objectId = readD(); // Target object Identifier _originX = readD(); _originY = readD(); _originZ = readD(); _actionId = readC(); // Action identifier : 0-Simple click, 1-Shift click } @Override protected void runImpl() { log.debug("Action: " + _actionId + ", objectId: " + _objectId); // Get the current L2PcInstance of the player final L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) return; if (activeChar.inObserverMode()) { activeChar.sendPacket(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } // If the player is the requester of a transaction if (activeChar.getActiveRequester() != null) { activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } // If requested object doesn't exist final L2Object obj = (activeChar.getTargetId() == _objectId) ? activeChar.getTarget() : L2World.getInstance().findObject(_objectId); if (obj == null) { activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } switch (_actionId) { case 0: obj.onAction(activeChar); break; case 1: if (obj instanceof L2Character && ((L2Character) obj).isAlikeDead()) obj.onAction(activeChar); else obj.onActionShift(getClient()); break; default: // Invalid action detected (probably client cheating), log this log.warn(activeChar.getName() + " requested invalid action: " + _actionId); activeChar.sendPacket(ActionFailed.STATIC_PACKET); break; } } @Override protected boolean triggersOnActionRequest() { return false; } }