In Misc.java put
Code:private static final Random r = new Random(); public static int getRandomFlower() { return randomFlower[r.nextInt(randomFlower.length)]; }
then use
Code:c.getPA().object(Misc.getRandomFlower(), c.absX, c.absY, 0, 10);
|
Okay, well I followed a tutorial on how to add mithril seeds. It was a 50% working base. So I wanted to improve it by making it spawn random flowers, not just the one it was set to. I know I'm probably doing this wrong, but I'm still learning.
Here's the tutorial I followed: http://www.moparscape.org/smf/index....,529821.0.html
The only things I've changed in that is:
toCode:c.getPA().object(2981, c.absX, c.absY, 0, 10);
in Misc.java I addedCode:c.getPA().object(randomFlower, c.absX, c.absY, 0, 10);
I thought that would set the item ID's for the flowers that should be spawning on the ground after click mithril seeds. But it just spawns random object.Code:public int[] randomFlower = {2981, 2982, 2983, 2984, 2985};
I've also imported
import server.engine.util.Misc; in my clickingitems.java
Any help? Like I said, new to coding, not sure where to do these things. Any help/guidance will be appreciated. Not asking for any spoon-feeding. Just a little hint where this should go.
Thank you.
I get this error:
Compiling ShadowScape
src\server\util\Misc.java:194: cannot find symbol
symbol : class Random
location: class server.util.Misc
private static final Random r = new Random();
^
src\server\util\Misc.java:194: cannot find symbol
symbol : class Random
location: class server.util.Misc
private static final Random r = new Random();
^
src\server\util\Misc.java:197: non-static variable randomFlower cannot be refere
nced from a static context
return randomFlower[r.nextInt(randomFlower.length)];
^
src\server\util\Misc.java:197: non-static variable randomFlower cannot be refere
nced from a static context
return randomFlower[r.nextInt(randomFlower.length)];
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
Complete
Press any key to continue . . .
Open up Playerassistant.java and search for " Public Static Int Barrows" and paste this under the closing "}"
The numbers represent what the code of the object is, In this instance.Code:public static int[] Flowers = {2981, 2982, 2983, 2984, 2985};
Now search " randomBarrows" and you should find something like
Below that addCode:public int randomBarrows() { return Barrows[(int)(Math.random()*Barrows.length)]; }
After that open up clickitem and find the Mithril seeds "IF" statement, Replace the whole Mithril seed 'if' statement withCode:public int randomFlower() { return Flowers[(int)(Math.random()*Flowers.length)]; }
Compile and it should work!Code:if(itemId == 299) { int randomFlower = Misc.random(1588); if(randomFlower >= 0 && randomFlower <= 1588) { c.getItems().deleteItem(299, 1); c.getPA().walkTo(0, 1); c.getPA().object(c.getPA().randomFlower(), c.absX, c.absY, 0, 10); } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |