Give possitive feedback please. If I explained something wrong just correct me.
There isn't really anything to explain in Dialogue.
NOTE: You need to get the StackBag snippet by Jilic-Matt
Go into DialogueManager.java
this is in src/org/dementhium/content
First import this
Code:
import java.util.Random;
Search for
Under this if you are every wanting an npc to start a dialogue you need to put the case as the npc id
Under that add
Code:
case 2998: //Gambler
sendDialogue(player, HAPPY_TALKING, 2998, 12000, "My bag of cash contains " + player.getStackBag() + " coins.", "Wanna play me for it?");
return true;
This is the Gambler (2998). The number 12000 is the case number it will go to. HAPPY_TALKING is obviously the emotion the npc or you will be showing. Changing 2998 (not the case) will let the player talk.
I'll show some more emotions at the bottom but you should be able to find them at the very bottom of DialogueManager.java. The player.getStackBag is getting the StackBag method from player.java and sending it into this file.
Next search for
Under that add
Code:
case 12000:
sendOptionDialogue(player, new int[]{12001, -1}, "Alright", "Nah, I'm good");
return true;
This is sending 2 options with 2 arrarys.
The arrays are 12001 and -1. If the number is -1 than you want it to stop after you click continue if the number is anything else it will go to that case number. Like 12001 is the first option ("Alright") going into case 12001.
Now under that add
Code:
case 12001:
if (!player.getInventory().contains(995)) {
sendDialogue(player, MEAN_FACE, 2998, -1, "You need some money to play me!");
} else {
sendDialogue(player, HAPPY_TALKING, -1, 12002, "Alright.");
}
return true;
This is saying if you don't have and coins in your inventory than you won't play
If statements are like cause and effect. If you don't have this than you will be playing without gambling really
This "!" in front of this if statement means not or doesn't. You can remove this and figure out what your gonna do next
Code:
if (!player.getInventory().contains(995)) {
Under that add this
Code:
case 12002:
World.getWorld().getNpcs().getById(2998).animate(Animation.create(11900, 0));
World.getWorld().getNpcs().getById(2998).graphics(Graphic.create(2075, 0));
sendDisplayBox(player, 12003, "Rolling...");
player.animate(Animation.create(11900, 0));
player.graphics(Graphic.create(2075, 0));
return true;
case 12003:
Random dice = new Random();
int roll = 0;
int npcRoll = 0;
for (int counter = 1; counter <= 1; counter++) {
roll = 1 + dice.nextInt(100);
npcRoll = 1 + dice.nextInt(100);
if (npcRoll < roll) {
sendDialogue(player, WHAT_THE_CRAP, -1, 12004, "Ha loser! I rolled " + roll + " and you got " + npcRoll.);
} else if (npcRoll == roll) {
sendDialogue(player, MEAN_FACE, 2998, -1, "Shit! How did we tie with " + npcRoll);
} else if (npcRoll > roll) {
sendDialogue(player, MEAN_FACE, -1, 12005, "Fuck! How did you get " + npcRoll + "?! I only got " + roll + "?!");
}
}
return true;
his is a for loop. The 1 + dice.nextInt(100); is using the numbers 1 - 100.
The int counter = 1; counter <= 1; is making it so it will only put out 1 number. The counter++ is incrementing 1.
I can't really explain anything else about that, so go learn it yourself.
Code:
for (int counter = 1; counter <= 1; counter++) {
roll = 1 + dice.nextInt(100);
npcRoll = 1 + dice.nextInt(100);
After all that add this
Code:
case 12004:
sendDisplayBox(player, -1, "You recieved " + player.getStackBag() + " from the Gambler.");
player.getInventory().addItem(StackBag.STORED_STACK, player.getStackBag());
return true;
case 12005:
sendDisplayBox(player, -1, "You lost all of your cash to the Gambler");
player.addToBag();
return true;
This is getting the STORED_STACK item from from StackBag.java and giving it to the player. It will give all the coins put into the stackbag.
Code:
player.getInventory().addItem(StackBag.STORED_STACK, player.getStackBag());
Post errors
The only thing I won't help you with is getting the stackbag through the whole server.
Like everyone can see the deposits of the lost cash inside his stackbag