Oaterz
August 18th, 2010, 13:58
So I was going through some old ideas today, and I found one I never really thought of as an actual in-game feature.
Today, it changed.
What this is for
----------------------
Part 1 (aka Item Chest) will show you how to make a 'lottery' type item.
This part teaches you how to make it so when a player clicks an item, or 'opens' a box, they receive a random item(s).
Part 2 (aka Treasure Chest) will show you how to make a treasure box filled with goodies.
This part will teach you how to make it so when a player uses an item (Key) they will 'open' the chest and obtain item(s).
Part 1
----------------------
This is quite simple, and should work for all Delta based servers.
First, let's head into Item.java
Hit Ctrl+F and find this:
public static int randomPHat() {
Under the last '}' place this:
public static int randomLotteryChest() {
return LChest[(int) (Math.random() * LChest.length)];
}
Here's the breakdown:
The line
public static int randomLotteryChest() {
Tells it to create a new thing called randomLotteryChest()
The line
return LChest[(int) (Math.random() * LChest.length)];
Pretty much gives it a name.
No need to worry about that right now, we will get back to it later (You'll need it!).
NOTE: That's really all I know, because I'm not a 'coder' or 'programmer' as you may call them. :(
Anyways, let's move on, shall we?
Now, don't close Item.java, we aren't quite done yet.
Scroll back to the top and hit Ctrl+F again.
This time search for:
public static int crackers[] = { 1038, 1040, 1042, 1044, 1046, 1048 };
You see where it says 'crackers[]'? That's what we 'declared' earlier. (I think that's the term used for it. Please correct me if I am wrong)
Now, under that line paste:
public static int LChest[] = { ####, ####, ####, ####, ####, #### };
You need to change the '####' to any item ID you want. These will be the items drawn randomly from the 'lottery chest'.
Okay, you can now close Item.java, we are done with it (Yay)!
Now, open up potions.java, and search for:
case 315:
At the end of that where the '}' is, paste this:
case $$$$:
c.deleteItem($$$$, 1);
c.addItem(Item.randomLChest(), @);
c.sM("You open the chest and find an item.");
break;
Replace '$$$$' with the item ID of what the player clicks to get the item. I suggest 405, it's not used in most servers and it's a casket (chest).
Replace '@' with the ammount of items the player will recieve (they will be random).
Now save and close potions.java then compile and run. Pick up the item you set it for, and click it!
If there are any problems with this tutorial, please notify me by posting here.
Part 2
----------------------
No responses, so I guess I won't write this part till I feel like it.
Today, it changed.
What this is for
----------------------
Part 1 (aka Item Chest) will show you how to make a 'lottery' type item.
This part teaches you how to make it so when a player clicks an item, or 'opens' a box, they receive a random item(s).
Part 2 (aka Treasure Chest) will show you how to make a treasure box filled with goodies.
This part will teach you how to make it so when a player uses an item (Key) they will 'open' the chest and obtain item(s).
Part 1
----------------------
This is quite simple, and should work for all Delta based servers.
First, let's head into Item.java
Hit Ctrl+F and find this:
public static int randomPHat() {
Under the last '}' place this:
public static int randomLotteryChest() {
return LChest[(int) (Math.random() * LChest.length)];
}
Here's the breakdown:
The line
public static int randomLotteryChest() {
Tells it to create a new thing called randomLotteryChest()
The line
return LChest[(int) (Math.random() * LChest.length)];
Pretty much gives it a name.
No need to worry about that right now, we will get back to it later (You'll need it!).
NOTE: That's really all I know, because I'm not a 'coder' or 'programmer' as you may call them. :(
Anyways, let's move on, shall we?
Now, don't close Item.java, we aren't quite done yet.
Scroll back to the top and hit Ctrl+F again.
This time search for:
public static int crackers[] = { 1038, 1040, 1042, 1044, 1046, 1048 };
You see where it says 'crackers[]'? That's what we 'declared' earlier. (I think that's the term used for it. Please correct me if I am wrong)
Now, under that line paste:
public static int LChest[] = { ####, ####, ####, ####, ####, #### };
You need to change the '####' to any item ID you want. These will be the items drawn randomly from the 'lottery chest'.
Okay, you can now close Item.java, we are done with it (Yay)!
Now, open up potions.java, and search for:
case 315:
At the end of that where the '}' is, paste this:
case $$$$:
c.deleteItem($$$$, 1);
c.addItem(Item.randomLChest(), @);
c.sM("You open the chest and find an item.");
break;
Replace '$$$$' with the item ID of what the player clicks to get the item. I suggest 405, it's not used in most servers and it's a casket (chest).
Replace '@' with the ammount of items the player will recieve (they will be random).
Now save and close potions.java then compile and run. Pick up the item you set it for, and click it!
If there are any problems with this tutorial, please notify me by posting here.
Part 2
----------------------
No responses, so I guess I won't write this part till I feel like it.