Code:
package com.rs2.game.content.skills.agility;
import com.rs2.game.content.skills.SkillConstants;
import com.rs2.game.player.Client;
public class AgilityShortcut {
public enum ShortcutData {
/**
* Shortcut in Yannile. int[][] data expressed as (obj, destX, destY)
*/
YANNILE(16, new int[][] {
{
9301, 2575, 3112
}, {
9302, 2574, 3108
}
}, 30, 333, 6516);
private int levelRequired, xp, emote, interfaceId;
private int[][] data;
ShortcutData(int levelRequired, int[][] data, int xp, int emote, int interfaceId) {
this.levelRequired = levelRequired;
this.data = data;
this.xp = xp;
this.emote = emote;
this.interfaceId = interfaceId;
}
/**
* @return the shortcut levelRequired
*/
public int getLevelRequired() {
return levelRequired;
}
/**
* @return the shortcut data
*/
public int[][] getData() {
return data;
}
/**
* @return the shortcut xp
*/
public int getXp() {
return xp;
}
/**
* @return the shortcut emote
*/
public int getEmote() {
return emote;
}
/**
* @return the shortcut item interfaceId
*/
public int getInterfaceId() {
return interfaceId;
}
}
/**
* Collects data in the ShortcutData enum.
* @param objectType
* the shortcut object
* @return
* null if the shortcut object does not exist
*/
public static ShortcutData forId(int objectType) {
for (ShortcutData sd: ShortcutData.values()) {
for (int i = 0; i < sd.getData().length; i++) {
if (objectType == sd.getData()[i][0]) {
return sd;
}
}
}
return null;
}
/**
* Agility shortcut main stuff here. TODO Make into an event.
* @param c
* client
* @param objectType
* the shortcut object id
* @return
* false if the object id is an agility shortcut object
*/
public static boolean doShortcut(Client c, int objectType) {
ShortcutData sd = forId(objectType);
if (sd == null) {
return true;
}
for (int i = 0; i < sd.getData().length; i++) {
if (objectType == sd.getData()[i][0]) {
if (c.playerLevel[SkillConstants.AGILITY] < sd.getLevelRequired()) {
c.getActionSender().sendGiveItemNpc("You need an Agility level of" + sd.getLevelRequired() + " to do this.", sd.getInterfaceId());
return true;
}
c.getPA().movePlayer(sd.getData()[i][1], sd.getData()[i][2], 0);
c.getActionSender().sendMessage("You pass the shortcut.");
}
}
return false;
}
}
first click object packet above the switch statement:
Code:
if(AgilityShortcut.doShortcut(c, objectType)){
//hook
}
item npc message method, ripped:
Code:
public void sendGiveItemNpc(String text, int item) {
c.getActionSender().sendFrame126(text, 308);
c.getActionSender().sendFrame246(307, 200, item);
c.getActionSender().sendFrame164(306);
}