Integrigating your server with my Cheezscape pk Revamped dialogue system..
To add:
First, go into process, find and delete:
Code:
if (NpcWanneTalk == 2)
{ // Bank Booth
if (GoodDistance2(absX, absY, skillX, skillY, 1) == true)
{
NpcDialogue = 1;
NpcTalkTo = GetNPCID(skillX, (skillY - 1));
NpcWanneTalk = 0;
}
}
else if (NpcWanneTalk > 0)
{
if (GoodDistance2(absX, absY, skillX, skillY, 1) == true)
{
NpcDialogue = NpcWanneTalk;
NpcTalkTo = GetNPCID(skillX, skillY);
NpcWanneTalk = 0;
}
}
if (NpcDialogue > 0 && NpcDialogueSend == false)
{
/* W/E IN HERE */
}
And once you have deleted that, add this into process:
Code:
if (conversationId > 0 && inDialogue) dialogueUpdate();
Simple.
Now, create a new class, call it Dialogue, then add this to it:
Code:
/**
* Possibly another smart class =)
* @author momosherilly
* Handles dialogues and dialogue clicks..
*/
public class Dialogue
{
public int pId = 0;
public Dialogue(int pId)
{
this.pId = pId;
}
public void optionSelect(int actionButtonId)
{
client p = (client) server.playerHandler.players[pId];
switch (actionButtonId)
{
case 9157 :/* Two options - 1/2 */
switch (p.conversationId)
{
case 2 :
p.startDialogue(3, p.talkId);
break;
}
break;
case 9158 :/* Two options - 2/2 */
switch (p.conversationId)
{
case 2 :
p.startDialogue(4, p.talkId);
break;
}
break;
}
}
public void dialogueClick(int conversationId, int dialogueId)
{
client p = (client) server.playerHandler.players[pId];
if (!p.GoodDistance(p.absX, p.absY, p.packetClickX, p.packetClickY, 1)) return;
switch (conversationId)
{
case 1 :
/* Calls for the next dialogue */
nextDialogue();
break;
/*
* If anything is not set on top, then close dialogue.. Give creds to momo!
*/
default :
stopDialogue();
}
}
public void startDialogue(int conversationId, int x, int y)
{
client p = (client) server.playerHandler.players[pId];
switch (conversationId)
{
/*
* Testing..
*/
case 1 :
p.NTalk1Momo("Haa - Haa- Haa! Hello "+p.playerName, 606);
break;
case 2 :
p.POption2Momo("Hello..", "Goodbye..");
break;
case 3 :
p.PTalk1Momo("Hello..", 592);
break;
case 4 :
p.PTalk1Momo("Haa - Haa - Haa! Good bye.", 592);
break;
}
}
public void nextDialogue()
{
client p = (client) server.playerHandler.players[pId];
p.conversationId++;
p.dialogueUpdate();
return;
}
public void stopDialogue()
{
client p = (client) server.playerHandler.players[pId];
p.conversationId = -1;
p.talkId = -1;
p.talkingToNPC = -1;
p.inDialogue = false;
p.removeScreens();
return;
}
}
Now, add this into client:
Code:
public int talkId = 0;
public void removeScreens()
{
outStream.createFrame(219);
flushOutStream();
}
public void startDialogue(int convoId, int talkingId)
{
conversationId = convoId;
dialogueId = 1;
talkId = talkingId;
inDialogue = true;
dialogueUpdate();
}
public void PTalk1Momo(String text, int anim)
{ // Player talk
// You don't need for now, playerName = misc.fixCase(playerName);
sendFrame200(969, anim);
sendFrame126(playerName.replaceAll("_", " "), 970);
sendFrame126(text, 971);
sendFrame185(969);
sendFrame164(968);
}
public void NTalk1Momo(String text, int anim)
{ // NPC talk
sendFrame200(4883, anim);
sendFrame126(GetNpcName(talkId).replaceAll("_", " "), 4884);
sendFrame126(text, 4885);
sendFrame75(talkId, 4883);
sendFrame164(4882);
}
public void POption2Momo(String text, String text2)
{ // Player 2 options
sendFrame126(text, 2461);
sendFrame126(text2, 2462);
sendFrame164(2459);
}
public void dialogueUpdate()
{
/*
* Created by momosherilly..
*/
new Dialogue(playerId).startDialogue(conversationId, skillX, skillY);
inDialogue = false;
}
Then add this into Player:
Code:
public int conversationId = 0;
public int talkingToNPC = 0;
public boolean inDialogue = false;
public int dialogueId = 0;
Now find:
Code:
parseIncomingPackets()
and replace statement switch 40, to this:
Code:
/*
* Handled AGAIN now WAY MORE CLEANER DIALOGUE SYSTEM -BY MOMOSHERILLY <(^.^)>
*/
case 40 :
new Dialogue(playerId).dialogueClick(conversationId, dialogueId);
break;
Now go edit action buttons(case 185), and replace these statement switches(if you have them):
Code:
case 9157 :
case 9158 :
new Dialogue(playerId).optionSelect(actionButtonId);
break;
Now find:
and add this under it:
Code:
/*
* NEW DIALOGUE BASE BY MOMOSHERILLY!
*/
if (conversationId > 0)
{
conversationId = 0;
talkingToNPC = 0;
talkId = 0;
inDialogue = false;
removeScreens();
}
To use:
Just use:
Code:
skillX = server.npcHandler.npcs[NPCSlot].absX;
skillY = server.npcHandler.npcs[NPCSlot].absY;
startDialogue(## CONVERSATION ID ##, THE NPC);
Any errors, anything missing, if it doesn't seem to work, or you need help, post!
Oh, example(BANKERS){Add this in case 155 - search for parseIncomingPackets()}:
Code:
if(NPCID >= 494 && NPCID <= 495) startDialogue(1, NPCID);