I've been away for a while, so I'm going to post my dialog I'm working on. This continues dialog with player and npc faces + multi lines. *credits to pali and who ever released the player face one.
Video: http://www.youtube.com/watch?v=UjelqfWFsDc
replace NPCOption1.java with this
in PacketManager.java add this packet.Code:/*
* Class NPCOption1
*
* Version 1.0
*
* Friday, August 22, 2008
*
* Created by Palidino76
*/
package palidino76.rs2.io.packets;
import palidino76.rs2.Engine;
import palidino76.rs2.players.Player;
import palidino76.rs2.util.Misc;
public class NPCOption1 implements Packet {
/**
* Handles the first NPC option.
* @param p The Player which the frame should be handled for.
* @param packetId The packet id this belongs to.
* @param packetSize The amount of bytes being recieved for this packet.
*/
public void handlePacket(Player p, int packetId, int packetSize) {
if (p == null || p.stream == null) {
return;
}
if (!p.npcOption1) {
int npcId = p.stream.readUnsignedWordA();
if (npcId <= 0 || npcId >= Engine.npcs.length || Engine.npcs[npcId] == null) {
return;
}
p.clickId = npcId;
p.clickX = Engine.npcs[npcId].absX;
p.clickY = Engine.npcs[npcId].absY;
if (Misc.getDistance(p.absX, p.absY, p.clickX, p.clickY) > 30) {
return;
}
p.npcOption1 = true;
}
if (p.clickId <= 0 || p.clickId >= Engine.npcs.length || Engine.npcs[p.clickId] == null) {
p.npcOption1 = false;
return;
}
if (Misc.getDistance(p.absX, p.absY, p.clickX, p.clickY) > 1) {
return;
}
p.npcOption1 = false;
talk(p, p.clickId);
}
public void talk(Player p, int npcId) {
reset(p);
switch (npcId) {
case 2:
p.stage[0] = true;
npcOneLine(p, 0, 9827, "Hans", "How are you on this lovely day?");
break;
case 3:
p.stage[1] = true;
npcOneLine(p, 1, 9827, "Man", "I am the MAN!");
break;
default:
Misc.println("[" + p.username + "] Unhandled npc option 1: " + p.clickId);
break;
}
}
public void npcOneLine(Player p, int npcId, int animation, String npcName, String message) {
p.frames.showChatboxInterface(p, 241);
p.frames.animateInterfaceId(p, animation, 241, 2);
p.frames.setNPCId(p, npcId, 241, 2);
p.frames.setString(p, npcName, 241, 3);
p.frames.setString(p, message, 241, 4);
}
public void npcTwoLine(Player p, int npcId, int animation, String npcName, String message, String message2) {
p.frames.showChatboxInterface(p, 242);
p.frames.animateInterfaceId(p, animation, 242, 2);
p.frames.setNPCId(p, npcId, 242, 2);
p.frames.setString(p, npcName, 242, 3);
p.frames.setString(p, message, 242, 4);
p.frames.setString(p, message2, 242, 5);
}
public void npcThreeLine(Player p, int npcId, int animation, String npcName, String message, String message2, String message3) {
p.frames.showChatboxInterface(p, 243);
p.frames.animateInterfaceId(p, animation, 243, 2);
p.frames.setNPCId(p, npcId, 243, 2);
p.frames.setString(p, npcName, 243, 3);
p.frames.setString(p, message, 243, 4);
p.frames.setString(p, message2, 243, 5);
p.frames.setString(p, message3, 243, 6);
}
public void npcFourLine(Player p, int npcId, int animation, String npcName, String message, String message2, String message3, String message4) {
p.frames.showChatboxInterface(p, 244);
p.frames.animateInterfaceId(p, animation, 244, 2);
p.frames.setNPCId(p, npcId, 244, 2);
p.frames.setString(p, npcName, 244, 3);
p.frames.setString(p, message, 244, 4);
p.frames.setString(p, message2, 244, 5);
p.frames.setString(p, message3, 244, 6);
p.frames.setString(p, message4, 244, 7);
}
public void playerOneLine(Player p, int animation, String message) {
p.frames.showChatboxInterface(p, 64);
p.frames.animateInterfaceId(p, animation, 64, 2);
p.frames.setId(p, 64, 2);
p.frames.setString(p, p.username, 64, 3);
p.frames.setString(p, message, 64, 4);
}
public void playerTwoLine(Player p, int animation, String message, String message2) {
p.frames.showChatboxInterface(p, 65);
p.frames.animateInterfaceId(p, animation, 65, 2);
p.frames.setId(p, 65, 2);
p.frames.setString(p, p.username, 65, 3);
p.frames.setString(p, message, 65, 4);
p.frames.setString(p, message2, 65, 5);
}
public void playerThreeLine(Player p, int animation, String message, String message2, String message3) {
p.frames.showChatboxInterface(p, 66);
p.frames.animateInterfaceId(p, animation, 66, 2);
p.frames.setId(p, 66, 2);
p.frames.setString(p, p.username, 66, 3);
p.frames.setString(p, message, 66, 4);
p.frames.setString(p, message2, 66, 5);
p.frames.setString(p, message3, 66, 6);
}
public void playerFourLine(Player p, int animation, String message, String message2, String message3, String message4) {
p.frames.showChatboxInterface(p, 67);
p.frames.animateInterfaceId(p, animation, 67, 2);
p.frames.setId(p, 67, 2);
p.frames.setString(p, p.username, 67, 3);
p.frames.setString(p, message, 67, 4);
p.frames.setString(p, message2, 67, 5);
p.frames.setString(p, message3, 67, 6);
p.frames.setString(p, message4, 67, 7);
}
public boolean checkContinue(Player p) {
if (p.stage[0]) {
switch (p.iStage) {
case 0:
playerOneLine(p, 9846, "Npc chains work!");
p.iStage++;
break;
case 1:
npcOneLine(p, 0, 9827, "Hans", "Well, fuck you too!");
p.iStage++;
break;
case 2:
npcFourLine(p, 0, 9827, "Hans", "Well, I'm sorry for that.", "Here take this,", "just please don't hurt me.", "I beg you!");
Engine.playerItems.addItem(p, 1042, 1);
p.iStage++;
break;
default:
return false;
}
return true;
} else if (p.stage[1]) {
switch (p.iStage) {
case 0:
playerOneLine(p, 9846, "Cool?");
p.iStage++;
break;
case 1:
npcOneLine(p, 1, 9827, "Man", "Indeed!");
p.iStage++;
break;
case 2:
playerTwoLine(p, 9846, "So what is this place?", "Am I in jail?");
p.iStage++;
break;
case 3:
npcOneLine(p, 1, 9827, "Man", "Lawlz you are soooo drunk...");
p.iStage++;
break;
case 4:
playerFourLine(p, 9846, "Wow", "WILL", "YOU", "DIE!");
p.iStage++;
break;
default:
return false;
}
return true;
} else
return false;
}
public void reset(Player p) {
for (int i = 0; i < p.stage.length; i++) {
p.stage[i] = false;
}
p.iStage = 0;
}
}
in Player.java add these.Code:case 63:
/*
* Click here to continue.
*/
if (!npcOption1.checkContinue(p))
p.frames.removeChatboxInterface(p);
break;
Thank you nicole for pointing that bug out. ;]Code:public boolean[] stage = new boolean[2];
public int iStage;
It's pretty self explanitory, if you need help using it I can make a video, just request it. If you don't like it don't post. Have fun.