• Log in or sign up for an account here: https://www.sythe.org/login

[317] Creating Dialogue

KingGhostly

Active Member
Joined
Oct 8, 2011
Sythe Gold
0
Messages
179
Purpose: Teach you how to make npc dialogues

Difficulty: 7-9

Assumed Knowledge: you should know how to add voids

Server Tested on: Cheezscape

Classes Modified: client.java



Note: This is 100% Mine, please do not leech and post it on any other website, thanks!

Step 1:
Okay, first of all you need to open your client.java, you do not need to have any other files open.

First of, you get the ID of the npc you want to make talk, so I will use 2244 as an example. (This is an example)

Okay, now searh for:
Code:
case 155: //first Click npc
Now scroll down until you see something like:
Code:
 } else if (NPCID == 494 || NPCID == 495) { /*Banking*/
					skillX = server.npcHandler.npcs[NPCSlot].absX;
					skillY = server.npcHandler.npcs[NPCSlot].absY;
					NpcWanneTalk = 1;
				}
Step 2:
Under that, you need to add this:
Code:
else if (NPCID == 2244) {    
               skillX = server.npcHandler.npcs[NPCSlot].absX;
               skillY = server.npcHandler.npcs[NPCSlot].absY;
               NpcWanneTalk = 1339;
}
Step 3:
The two parts that are green are very important, the first one – 2244 has to be your npc ID , so whatever the npc ID is, it has to go in there, and the second bold 1339 is a case, Now you need to make cases for the chat and cases for the accepting or declining.

Okay now for the cases, look for:
Code:
public void UpdateNPCChat() {
Now under that, you will see case 1, case 2, and so on. Now just add in your case like so:
Code:
case 1339:
            sendFrame126(GetNpcName(NpcTalkTo), 4902);
            sendFrame126("", 4903);
            sendFrame126("HEY WHATS UP ADD YOUR TEXT HERE", 4904);
            sendFrame126("MORE TEXT HERE", 4905);
            sendFrame126("", 4906);
            sendFrame75(NpcTalkTo, 4901);
            sendFrame164(4900);
            NpcDialogueSend = true;
            break;
Note: The cases have to go in order, for example, the next case would be 1340.

Now, if you want there to be a choice dialogue then you need to add another case like so:
Code:
case 1340:
            sendFrame171(1, 2465);
            sendFrame171(0, 2468);
            sendFrame126("Select an Option", 2460);
            sendFrame126("Yes, please", 2461);
            sendFrame126("No, Thank you.", 2462);
            sendFrame164(2459);
            NpcDialogueSend = true;
            break;
Step 4:
Search for: case 40: and it should look something like this:
Code:
case 40:
				if (NpcDialogue == 1 || NpcDialogue == 3 ||
Note: There will be a bunch more NpcDialogue Numbers.

Click anywhere after a set of lines (||) and add:
Code:
NpcDialogue == 1339
Example:
It should look something likes thise:
Code:
if (NpcDialogue == 1|| [B][U]NpcDialouge == 1339[/U][/B] ||
And so on..

Step 5:
Okay, now first is the “yes, please” ok clicking this option (which is also the first option in the dialogue) will require some coding in case 9157:
so look for case 9157: and you should see something like this:
Code:
case 9157:
						if (NpcDialogue == 2) {
							NpcDialogue = 0;
							NpcDialogueSend = false;
							openUpBank();
						} else if (NpcDialogue == 4) { //Aubury
							NpcDialogue = 0;
							NpcDialogueSend = false;
							openUpShop(2);
						}
Note: This bit of code...
Code:
if (NpcDialogue == 2) {
Refers to the cases we were discussing earlier,

This bit of code...
Code:
NpcDialogue = 0;
							NpcDialogueSend = false;
							openUpBank();
Is what it does once you have clicked on the “yes, please” , so using our example we will add our code (we will pretend it was to get teleported somewhere)

Add this near the others:
Code:
else if (NpcDialogue == 1340) { //npc 1002
							NpcDialogue = 0;
							NpcDialogueSend = false;
							teleportToX = 1234;
							teleportToY = 1234;
						}
Step 6:
Okay, now for the “no, thank you” ok clicking this option (which is the second option in the dialogue) which will require some coding in case 9158:
So look for case 9158: (under case 9157: ) and you will see something like this:
Code:
case 9158:
						if (NpcDialogue == 2) {
							NpcDialogue = 0;
							NpcDialogueSend = false;
							openUpPinSettings();
						} else if (NpcDialogue == 4) {
							NpcDialogue = 5;
							NpcDialogueSend = false;
						                  }else if (NpcDialogue == 41){
                     NpcDialogue = 0;
                     NpcDialogueSend = false;
                     RemoveAllWindows();
                  }
So this has the same concept as the case 9157, meaning that the...
Code:
else if (NpcDialogue == 1340)
'2244' has to be the npc dialogue case. (Remember, this is just an example)


This does require a little bit of thinking, I worked hard on this. I'm just trying to help the 'Future' Programmers out a little bit.


Credits: KingGhostly (Me)
 
Pretty basic guide, and would obviously only work if you already had a dialogue system in place
 
Runescape Gamblingrunescape gambling
Back
Top