Code:
package com.rs.game.player.dialogues;
import com.rs.cache.loaders.NPCDefinitions;
import com.rs.game.player.actions.Slayer;
import com.rs.utils.ShopsHandler;
import com.rs.game.player.content.slayer.SlayerMaster;
import com.rs.game.player.actions.slayer.SlayerTask;
public class Turael extends Dialogue {
/**
* Starts the dialogue
*/
public Turael() {
}
@Override
public void start() {
npcId = (Integer) parameters[0];
sendEntityDialogue(SEND_1_TEXT_CHAT,
new String[] { NPCDefinitions.getNPCDefinitions(npcId).name,
"Hey! What would you like?" },
(byte) 1, npcId, 9827);
}
@Override
public void run(int interfaceId, int componentId) {
sendEntityDialogue(SEND_4_OPTIONS, new String[] {
SEND_DEFAULT_OPTIONS_TITLE,
"How many monsters do I have left?",
"What do you have in your shop?", "Give me a tip.",
"Nothing." }, IS_PLAYER, player.getIndex(),
9827);
stage = 0;
sendEntityDialogue(SEND_4_OPTIONS, new String[] {
SEND_DEFAULT_OPTIONS_TITLE, "Please give me a task.",
"What do you have in your shop?", "Give me a tip.",
"Nothing." }, IS_PLAYER, player.getIndex(),
9827);
stage = 1;
if (stage == 0 || stage == 1) {
if (componentId == 1) {
SlayerTask task = player.getSlayerTask();
if (task != null && stage == 0) {
sendEntityDialogue(
SEND_1_TEXT_CHAT,
new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"You're current assigned to kill "
+ task.getName().toLowerCase()
+ " only " + task.getAmount()
+ " more to go." }, IS_NPC, npcId,
9827);
} else {
Slayer.submitRandomTask(player);
sendEntityDialogue(
SEND_1_TEXT_CHAT,
new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"Your new task is to kill "
+ player.getSlayerTask().getName()
.toLowerCase() + "." },
IS_NPC, npcId, 9827);
}
stage = -1;
} else if (componentId == 2) {
sendEntityDialogue(
SEND_1_TEXT_CHAT,
new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"I have multiple items for sale." }, IS_NPC,
npcId, 9827);
ShopsHandler.openShop(player, 29);
stage = -1;
} else if (componentId == 3) {
sendEntityDialogue(
SEND_1_TEXT_CHAT,
new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"I currently dont have any tips for you now." },
IS_NPC, npcId, 9827);
stage = -1;
} else {
end();
}
stage = 2;
sendEntityDialogue(SEND_2_OPTIONS, new String[] {
SEND_DEFAULT_OPTIONS_TITLE, "What do you have in your shop?", "Nothing." },
IS_PLAYER, player.getIndex(), 9827);
stage = 3;
if (stage == 3) {
if (componentId == 1) {
if (player.getSlayerTask() != null) {
sendEntityDialogue(
SEND_1_TEXT_CHAT,
new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"I cannot teach you until your slayer task is complete. Come back later." },
IS_NPC, npcId, 9827);
return;
}
sendEntityDialogue(SEND_1_TEXT_CHAT, new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"You are now under my wings." }, IS_NPC, npcId,
9827);
player.setSlayerMaster(Master.forId(npcId));
if (componentId == 2) {
sendEntityDialogue(SEND_1_TEXT_CHAT, new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"I have multiple items for sale." }, IS_NPC, npcId,
9827);
ShopsHandler.openShop(player, 29);
} else {
end();
}
}
@Override
public void finish() {
}
/**
* Declares the npc ID
*/
private int npcId;
}
}