activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), action.value));
return;
}
final L2Object target = activeChar.getTarget();
final L2Summon pet = activeChar.getPet();
if(usePet && (pet == null || pet.isOutOfControl()))
{
activeChar.sendActionFailed();
return;
}
// Скиллы петов
if(action.type == 2)
{
// TODO перенести эти условия в скиллы
if(action.id == 1000 && !target.isDoor()) // Siege Golem - Siege Hammer
{
activeChar.sendActionFailed();
return;
}
if((action.id == 1039 || action.id == 1040) && (target.isDoor() || target instanceof L2SiegeHeadquarterInstance)) // Swoop Cannon (не может атаковать двери и флаги)
{
activeChar.sendActionFailed();
return;
}
UseSkill(action.value);
return;
}
switch(action.id)
{
// Действия с игроками:
case 0: // Сесть/встать
// На страйдере нельзя садиться
if(activeChar.isMounted())
{
activeChar.sendActionFailed();
break;
}
int distance = (int) activeChar.getDistance(activeChar.getTarget());
if(target != null && !activeChar.isSitting() && target instanceof L2StaticObjectInstance && ((L2StaticObjectInstance) target).getType() == 1 && distance <= L2Character.INTERACTION_DISTANCE)
{
ChairSit cs = new ChairSit(activeChar, ((L2StaticObjectInstance) target).getStaticObjectId());
activeChar.sendPacket(cs);
activeChar.sitDown();
activeChar.broadcastPacket(cs);
break;
}
if(activeChar.isFakeDeath())
{
activeChar.breakFakeDeath();
activeChar.updateEffectIcons();
}
else if(activeChar.isSitting())
{
activeChar.standUp();
}
else
{
activeChar.sitDown();
}
break;
case 1: // Изменить тип передвижения, шаг/бег
if(activeChar.isRunning())
{
activeChar.setWalking();
}
else
{
activeChar.setRunning();
}
activeChar.sendUserInfo(true);
break;
case 7: // Next Target
L2Character nearest_target = null;
for(L2Character cha : L2World.getAroundCharacters(activeChar, 400, 200))
{
if(cha != null && !cha.isAlikeDead())
{
if((nearest_target == null || activeChar.getDistance3D(cha) < activeChar.getDistance3D(nearest_target)) && cha.isAutoAttackable(activeChar))
{
nearest_target = cha;
}
}
}
if(nearest_target != null && activeChar.getTarget() != nearest_target)
{
activeChar.setTarget(nearest_target);
if(activeChar.getTarget() == nearest_target)
{
if(nearest_target.isNpc())
{
activeChar.sendPacket(new MyTargetSelected(nearest_target.getObjectId(), activeChar.getLevel() - nearest_target.getLevel()));
activeChar.sendPacket(nearest_target.makeStatusUpdate(StatusUpdate.CUR_HP, StatusUpdate.MAX_HP));
activeChar.sendPacket(new ValidateLocation(nearest_target), Msg.ActionFail);
}
else
{
activeChar.sendPacket(new MyTargetSelected(nearest_target.getObjectId(), 0));
}
}
return;
}
break;
case 10: // Запрос на создание приватного магазина продажи
case 61: // Запрос на создание приватного магазина продажи (Package)
{
if(activeChar.isInTransaction())
{
activeChar.getTransaction().cancel();
}
if(activeChar.getTradeList() != null)
{
activeChar.getTradeList().removeAll();
activeChar.sendPacket(new SendTradeDone(0));
}
else
{
activeChar.setTradeList(new L2TradeList(0));
}
activeChar.getTradeList().updateSellList(activeChar, activeChar.getSellList());
activeChar.setPrivateStoreType(L2Player.STORE_PRIVATE_NONE);
activeChar.standUp();
activeChar.broadcastUserInfo(true);
if(!activeChar.checksForShop(false))
{
activeChar.sendActionFailed();
return;
}
activeChar.sendPacket(new PrivateStoreManageList(activeChar, _actionId == 61));
break;
}
case 28: // Запрос на создание приватного магазина покупки
{
if(activeChar.isInTransaction())
{
activeChar.getTransaction().cancel();
}
if(activeChar.getTradeList() != null)
{
activeChar.getTradeList().removeAll();
activeChar.sendPacket(new SendTradeDone(0));
}
else
{
activeChar.setTradeList(new L2TradeList(0));
}
activeChar.setPrivateStoreType(L2Player.STORE_PRIVATE_NONE);
activeChar.standUp();
activeChar.broadcastUserInfo(true);
if(!activeChar.checksForShop(false))
{
activeChar.sendActionFailed();
return;
}
activeChar.sendPacket(new PrivateStoreManageListBuy(activeChar));
}
break;
case 37: // Создание магазина Common Craft
{
if(activeChar.isInTransaction())
{
activeChar.getTransaction().cancel();
}
if(activeChar.getCreateList() == null)
{
activeChar.setCreateList(new L2ManufactureList());
}
activeChar.setPrivateStoreType(L2Player.STORE_PRIVATE_NONE);
activeChar.standUp();
activeChar.broadcastUserInfo(true);
if(!activeChar.checksForShop(true))
{
activeChar.sendActionFailed();
return;
}
activeChar.sendPacket(new RecipeShopManageList(activeChar, true));
break;
}
case 51: // Создание магазина Dwarven Craft
{
if(!activeChar.checksForShop(true))
{
activeChar.sendActionFailed();
return;
}
if(activeChar.getCreateList() == null)
{
activeChar.setCreateList(new L2ManufactureList());
}
activeChar.setPrivateStoreType(L2Player.STORE_PRIVATE_NONE);
activeChar.standUp();
activeChar.broadcastUserInfo(true);
activeChar.sendPacket(new RecipeShopManageList(activeChar, false));
break;
}
case 96: // Quit Party Command Channel?
_log.info("96 Accessed");
break;
case 97: // Request Party Command Channel Info?
_log.info("97 Accessed");
break;
// Действия с петами:
case 15:
case 21: // Follow для пета
if(pet != null)
{
pet.setFollowTarget(pet.getPlayer());
pet.setFollowStatus(!pet.isFollow(), true);
}
break;
case 16:
case 22: // Атака петом
if(target == null || pet == target || pet.isDead())
{
activeChar.sendActionFailed();
return;
}
if(activeChar.isInOlympiadMode() && !activeChar.isOlympiadCompStart())
{
activeChar.sendActionFailed();
return;
}
// Sin Eater
if(pet.getTemplate().getNpcId() == PetDataTable.SIN_EATER_ID)
{
return;
}
if(!_ctrlPressed && !target.isAutoAttackable(activeChar))
{
pet.setFollowTarget((L2Character) target);
pet.setFollowStatus(true, true);
return;
}
if(!target.isMonster() && (pet.isInZonePeace() || target.isInZonePeace()))
{
activeChar.sendPacket(Msg.YOU_MAY_NOT_ATTACK_THIS_TARGET_IN_A_PEACEFUL_ZONE);
return;
}
if(activeChar.getLevel() + 20 <= pet.getLevel())
{
activeChar.sendPacket(Msg.THE_PET_IS_TOO_HIGH_LEVEL_TO_CONTROL);
return;
}
if(!target.isDoor() && pet.isSiegeWeapon())
{
activeChar.sendPacket(Msg.INVALID_TARGET);
return;
}
pet.getAI().Attack(target, _ctrlPressed, _shiftPressed);
break;
case 17:
case 23: // Отмена действия у пета
pet.setFollowTarget(pet.getPlayer());
pet.setFollowStatus(pet.isFollow(), true);
break;
case 19: // Отзыв пета
if(pet.isDead())
{
activeChar.sendPacket(Msg.A_DEAD_PET_CANNOT_BE_SENT_BACK, Msg.ActionFail);
return;
}
if(pet.isInCombat())
{
activeChar.sendPacket(Msg.A_PET_CANNOT_BE_SENT_BACK_DURING_BATTLE, Msg.ActionFail);
break;
}
if(pet.isPet() && pet.getCurrentFed() < 0.55 * pet.getMaxFed())
{
activeChar.sendPacket(Msg.YOU_CANNOT_RESTORE_HUNGRY_PETS, Msg.ActionFail);
break;
}
pet.unSummon();
break;
case 38: // Mount
if(activeChar.getTransformation() != 0)
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(pet == null || !pet.isMountable())
{
if(activeChar.isMounted())
{
if(activeChar.isFlying() && !activeChar.checkLandingState()) // Виверна
{
activeChar.sendPacket(Msg.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_AT_THIS_LOCATION, Msg.ActionFail);
return;
}
activeChar.setMount(0, 0, 0);
}
}
else if(activeChar.isMounted() || activeChar.isInVehicle())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isDead())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(pet.isDead())
{
activeChar.sendPacket(Msg.A_DEAD_PET_CANNOT_BE_RIDDEN);
}
else if(activeChar.isInDuel())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isInCombat() || pet.isInCombat())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isFishing())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isSitting())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isCursedWeaponEquipped())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isCombatFlagEquipped() || activeChar.isTerritoryFlagEquipped())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isCastingNow())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else if(activeChar.isParalyzed())
{
activeChar.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
}
else
{
activeChar.getEffectList().stopEffect(L2Skill.SKILL_EVENT_TIMER);
activeChar.setMount(pet.getTemplate().npcId, pet.getObjectId(), pet.getLevel());
pet.unSummon();
}
break;
case 52: // Отзыв саммона
if(pet.isInCombat())
{
activeChar.sendPacket(Msg.A_PET_CANNOT_BE_SENT_BACK_DURING_BATTLE, Msg.ActionFail);
}
else
{
pet.unSummon();
}
break;
case 53:
case 54: // Передвинуть пета к цели
if(target != null && pet != target && !pet.isMovementDisabled())
{
pet.setFollowStatus(false, true);
ThreadPoolManager.getInstance().executePathfind(new Runnable()
{
public void run()
{
pet.moveToLocation(target.getLoc(), 100, true);
}
});
}
break;
case 1070: