Thread: Mithril Seed Spawning Random Flower

Results 1 to 5 of 5
  1. #1 Mithril Seed Spawning Random Flower 
    Registered Member
    Join Date
    Apr 2011
    Posts
    25
    Thanks given
    0
    Thanks received
    2
    Rep Power
    2
    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:

    Code:
    			c.getPA().object(2981, c.absX, c.absY, 0, 10);
    to

    Code:
    			c.getPA().object(randomFlower, c.absX, c.absY, 0, 10);
    in Misc.java I added
    Code:
    public int[] randomFlower = {2981, 2982, 2983, 2984, 2985};
    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.
    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.
    Reply With Quote  
     

  2. #2  
    Registered Member
    killamess's Avatar
    Join Date
    Dec 2007
    Age
    33
    Posts
    1,508
    Thanks given
    51
    Thanks received
    284
    Rep Power
    1956
    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);


    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Apr 2012
    Posts
    112
    Thanks given
    1
    Thanks received
    2
    Rep Power
    11
    Quote Originally Posted by killamess View Post
    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);
    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 . . .
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Apr 2012
    Posts
    112
    Thanks given
    1
    Thanks received
    2
    Rep Power
    11
    Open up Playerassistant.java and search for " Public Static Int Barrows" and paste this under the closing "}"

    Code:
    	public static int[] Flowers = {2981, 2982, 2983, 2984, 2985};
    The numbers represent what the code of the object is, In this instance.

    Now search " randomBarrows" and you should find something like

    Code:
    	public int randomBarrows() {
    		return Barrows[(int)(Math.random()*Barrows.length)];
    	}
    Below that add

    Code:
        public int randomFlower() {
            return Flowers[(int)(Math.random()*Flowers.length)];
        }
    After that open up clickitem and find the Mithril seeds "IF" statement, Replace the whole Mithril seed 'if' statement with

    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);
    }
    }
    Compile and it should work!
    Reply With Quote  
     

  5. #5  
    Registered Member
    killamess's Avatar
    Join Date
    Dec 2007
    Age
    33
    Posts
    1,508
    Thanks given
    51
    Thanks received
    284
    Rep Power
    1956
    put this with your other imports in Misc.java
    Code:
    import java.util.Random;
    and change

    Code:
    public int[] randomFlower = {2981, 2982, 2983, 2984, 2985};
    to

    Code:
    public static int[] randomFlower = {2981, 2982, 2983, 2984, 2985};


    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [667] Cheap Flower Game [Mithril Seeds]
    By `Basher in forum Snippets
    Replies: 16
    Last Post: 05-29-2016, 12:04 AM
  2. [Emulous/PI] Mithril Seeds/Flower game
    By Blaketon in forum Tutorials
    Replies: 6
    Last Post: 05-07-2012, 08:39 PM
  3. Replies: 5
    Last Post: 11-14-2011, 09:32 AM
  4. Mass Random seed stall stealing
    By Ho H0 Ho in forum Help
    Replies: 2
    Last Post: 07-28-2010, 11:26 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •