PDA

View Full Version : How to make a loot random. 508/525 or 508.



0r4nge ownz
January 1st, 2011, 17:16
Ok, so say if you wanted to add.. umm, crystal key on a chest.. or maybe thieving? you click a stall for a random item?

This is how you do it.
In player, Under all the variable's add this.
(A variable would look like this, "public boolean blah = false;" or "public int blah = 0;")




public static int Tutorial[] = {14484, 13736, 1046, 6856, 1050, 14595, 14603, 6858, 6860, 6862, 13113, 13115, 13111, 13110, 13109, 13101, 8950, 2631, 10548, 10549, 10547, 10887, 1057, 13263, 2978, 2980, 2982, 2984, 2986};
public static int RandomItemsTutorial()
{
return Tutorial[(int)(Math.random()*Tutorial.length)];
}

Change "Tutorial", to what you want it to be called.
Change the numbers, such as "14484" to what item ids you want.


Then, if you wanted to to the what ever it is you are doing a random loot.
Where ever you put the item id, put "p.RandomItemsTutorial()"

Anything else you need to ask, just leave a comment. i'l reply.

monster mash
January 1st, 2011, 17:21
so if you want to make it so that you go to an area, kill monsters get a specific item to open a chest, how and where would you put that?

0r4nge ownz
January 1st, 2011, 17:31
or you could make it like, the monster drops a treasure chest.

in itemselect.java

Case ****:
Engine.playerItems.addItem(p, p.RandomItems*****, 1);
break;


try that.

monster mash
January 1st, 2011, 17:44
But how would you make it open only if someone had the key?

0r4nge ownz
January 1st, 2011, 18:26
case 1727:
if (!Engine.playerItems.hasPlayerItem(p, 1523)) {
Engine.playerItems.addItem(p, p.RandomItemsTutorial(), 1);
}

thats it. change the case id, to the treasure chest id or w/e your using. then the 1523 is the item needed in invent.
and Tutorial change to w/e you set it tooin player.java.

You can also add delete item.
Engine.playerItems.deleteItem(p, *****, itemSlot, 1); //change ****** to item id you want to delete.

monster mash
January 1st, 2011, 18:33
in my case that would be the key that they need or 1523 right?

0r4nge ownz
January 2nd, 2011, 03:37
yup. you got it.

Tricky
January 2nd, 2011, 09:57
Thanks For This Very Helpfull. EDIT It Dont Work Sorry

0r4nge ownz
January 3rd, 2011, 18:04
No Problem.