@Override protected void runImpl() { // Get the current L2PcInstance of the player final L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) { return; } // Get the level of the used skill int level = activeChar.getSkillLevel(_skillId); if (level <= 0) { activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } // Get the L2Skill template corresponding to the skillID received from the client Skill skill = SkillData.getInstance().getSkill(_skillId, level); // Check the validity of the skill if (skill != null) { activeChar.setCurrentSkillWorldPosition(new Location(_x, _y, _z)); // normally magicskilluse packet turns char client side but for these skills, it doesn't (even // with correct target) activeChar.setHeading( Util.calculateHeadingFrom(activeChar.getX(), activeChar.getY(), _x, _y)); Broadcast.toKnownPlayers(activeChar, new ValidateLocation(activeChar)); activeChar.useMagic(skill, _ctrlPressed, _shiftPressed); } else { activeChar.sendPacket(ActionFailed.STATIC_PACKET); _log.warning("No skill found with id " + _skillId + " and level " + level + " !!"); } }
private int moveTo(L2Npc npc, int[] coords) { int time = 0; if (npc != null) { double distance = npc.calculateDistance(coords[0], coords[1], coords[2], true, false); int heading = Util.calculateHeadingFrom(npc.getX(), npc.getY(), coords[0], coords[1]); time = (int) ((distance / npc.getWalkSpeed()) * 1000); npc.setIsRunning(false); npc.disableCoreAI(true); npc.setIsNoRndWalk(true); npc.getAI() .setIntention( CtrlIntention.AI_INTENTION_MOVE_TO, new Location(coords[0], coords[1], coords[2], heading)); npc.getSpawn().setX(coords[0]); npc.getSpawn().setY(coords[1]); npc.getSpawn().setZ(coords[2]); } return time == 0 ? 100 : time; }