/* * This file is part of aion-unique <aion-unique.org>. * * aion-unique 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. * * aion-unique 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 aion-unique. If not, see <http://www.gnu.org/licenses/>. */ package com.aionemu.gameserver.skillengine.task; import com.aionemu.gameserver.model.gameobjects.Gatherable; import com.aionemu.gameserver.model.gameobjects.player.Player; import com.aionemu.gameserver.model.templates.GatherableTemplate; import com.aionemu.gameserver.model.templates.gather.Material; import com.aionemu.gameserver.network.aion.serverpackets.SM_GATHER_STATUS; import com.aionemu.gameserver.network.aion.serverpackets.SM_GATHER_UPDATE; import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE; import com.aionemu.gameserver.services.ItemService; import com.aionemu.gameserver.utils.PacketSendUtility; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; /** * @author ATracer * */ public class GatheringTask extends AbstractCraftTask { private GatherableTemplate template; private Material material; private ItemService itemService; @Inject public GatheringTask(ItemService itemService, @Assisted Player requestor, @Assisted Gatherable gatherable, @Assisted Material material, @Assisted int skillLvlDiff) { super(requestor, gatherable, gatherable.getObjectTemplate().getSuccessAdj(), gatherable.getObjectTemplate() .getFailureAdj(), skillLvlDiff); this.itemService = itemService; this.template = gatherable.getObjectTemplate(); this.material = material; } @Override protected void onInteractionAbort() { PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, 0, 0, 5)); //TODO this packet is incorrect cause i need to find emotion of aborted gathering PacketSendUtility.broadcastPacket(requestor, new SM_GATHER_STATUS(requestor.getObjectId(), responder.getObjectId(), 2)); } @Override protected void onInteractionFinish() { ((Gatherable) responder).getController().completeInteraction(); } @Override protected void onInteractionStart() { PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, 0, 0, 0)); PacketSendUtility.broadcastPacket(requestor, new SM_GATHER_STATUS(requestor.getObjectId(), responder.getObjectId(), 0), true); PacketSendUtility.broadcastPacket(requestor, new SM_GATHER_STATUS(requestor.getObjectId(), responder.getObjectId(), 1), true); } @Override protected void sendInteractionUpdate() { PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, currentSuccessValue, currentFailureValue, 1)); } @Override protected void onFailureFinish() { PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, currentSuccessValue, currentFailureValue, 1)); PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, currentSuccessValue, currentFailureValue, 7)); PacketSendUtility.broadcastPacket(requestor, new SM_GATHER_STATUS(requestor.getObjectId(), responder.getObjectId(), 3), true); } @Override protected void onSuccessFinish() { PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, currentSuccessValue, currentFailureValue, 2)); PacketSendUtility.sendPacket(requestor, new SM_GATHER_UPDATE(template, material, currentSuccessValue, currentFailureValue, 6)); PacketSendUtility.broadcastPacket(requestor, new SM_GATHER_STATUS(requestor.getObjectId(), responder.getObjectId(), 2), true); PacketSendUtility.sendPacket(requestor,SM_SYSTEM_MESSAGE.Gather_Success(Integer.toString(60))); itemService.addItem(requestor, material.getItemid(), 1); ((Gatherable)responder).getController().rewardPlayer(requestor); } }