Creating a simple leveling system

Discussion in 'Plugin Development' started by Shadow_tingBRO, Aug 30, 2019.

Thread Status:
Not open for further replies.
  1. Ok that title didnt make much sense , but i'm working on a plugin and a leveling up system for it. My aim is that so when a player places a block (and more actions in the future), depending on the blocks cost (I have a method which gets the cost of the material), it will give you a chance of leveling up. But the more the block is worth, the higher the chance you can level up. Is there a way I could create a random that decides this? Also taking in what level they are, the higher they are the more rare it is to level up. Is there any way I could do this?
     
  2. Offline

    CraftCreeper6

    @Shadow_tingBRO
    Well, yes. But it would just simply depend on a few things.

    The cost of a material, is that a float? Is there a maximum level? Would you not prefer an exp system?
     
  3. The materials range from 1 to about 3-5k max (beacons etc..), for now they are int's, all the prices are whole numbers but i can change that and its to do with skyblock and I dont think I would like a exp for this situation (other components to the plugin etc...)
     
  4. Offline

    CraftCreeper6

    @Shadow_tingBRO
    I wrote this little snippet in python. It works based on an equation that maxes out at about 98% at a block cost of 5000.

    See if you can convert it to Java and let me know how it is.

    Code:
    m = 0.016 # Reduce this number very slightly to decrease percentage chances
    c = 0
    
    def l(currentLevel, blockCost):
        chance = m*(blockCost/currentLevel) + c
       
        print(chance)
    Where m is the gradient and c is the adjustment.
     
  5. @CraftCreeper6
    Ill have a try thanks a lot, also the chance variable is what? A number out of something?

    Code:
           int worth = api.getMaterialHandler().getCost(/*'b' is the block*/b.getType());
            double  m = 0.016;// Reduce this number very slightly to decrease percentage chances
            double adjustment = 0;
            int level = data.getLevel();
            double chance = m*(worth/level) + adjustment;
    System.out.println(chance);
    
     
    Last edited: Aug 30, 2019
  6. Offline

    CraftCreeper6

    @Shadow_tingBRO
    The chance is a percentage out of 100, if the block cost goes over 5000 you'll have to adjust the value of m.
     
Thread Status:
Not open for further replies.

Share This Page