/* * 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 2, 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * http://www.gnu.org/copyleft/gpl.html */ package net.sf.l2j.gameserver.clientpackets; import java.nio.ByteBuffer; import java.util.logging.Logger; import net.sf.l2j.Config; import net.sf.l2j.gameserver.ClientThread; import net.sf.l2j.gameserver.model.L2ItemInstance; import net.sf.l2j.gameserver.model.L2PcInstance; import net.sf.l2j.gameserver.serverpackets.ActionFailed; import net.sf.l2j.gameserver.serverpackets.ExAutoSoulShot; import net.sf.l2j.gameserver.serverpackets.SystemMessage; /** * This class ... * * @version $Revision: 1.0.0.0 $ $Date: 2005/07/11 15:29:30 $ */ public class RequestAutoSoulShot extends ClientBasePacket { private static final String _C__CF_REQUESTAUTOSOULSHOT = "[C] CF RequestAutoSoulShot"; private static Logger _log = Logger.getLogger(RequestAutoSoulShot.class.getName()); // format cd private final int _unknown; //usually 5 ??? private final int _itemId; private final int _type; // 1 = on : 0 = off; /** * packet type id 0xcf * format: chdd * @param decrypt */ public RequestAutoSoulShot(ByteBuffer buf, ClientThread client) { super(buf, client); _unknown = readH(); _itemId = readD(); _type = readD(); } void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); // if (activeChar.getPrivateStoreType()==0 && activeChar.getTransactionRequester()==null && !activeChar.isDead() && activeChar.getAI().getIntention()==CtrlIntention.AI_INTENTION_IDLE) if (activeChar.getPrivateStoreType()==0 && activeChar.getTransactionRequester()==null && !activeChar.isDead()) { if (Config.DEBUG) _log.fine("AutoSoulShot:" + _itemId); if ( _type == 1) { L2ItemInstance item = activeChar.getInventory().findItemByItemId(_itemId); if (item == null) { _log.warning("Bad item id ("+_itemId+")was given to RequestAutoSoulShot."); activeChar.sendPacket(new ActionFailed()); return; } activeChar.addAutoSoulShot(_itemId); ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type); activeChar.sendPacket(atk); SystemMessage sm = new SystemMessage(614); sm.addString("The use of SS/(B)SPS will now be automated."); activeChar.sendPacket(sm); } else if ( _type == 0) { activeChar.removeAutoSoulShot(_itemId); ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type); activeChar.sendPacket(atk); SystemMessage sm = new SystemMessage(614); sm.addString("The automatic use of SS/(B)SPS will now be cancelled."); activeChar.sendPacket(sm); } } } /* (non-Javadoc) * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType() */ public String getType() { return _C__CF_REQUESTAUTOSOULSHOT; } }