Jump to content

upgrade system to +20


Monkuar
Go to solution Solved by .josh,

Recommended Posts

Need a little help here for my game.

 

Let's say you can upgrade items... I want users to upgrade to level 20.

 

Let's say, +1 is 80% chance and to get it to +20 would be 2% chance.

 

How would I go about this? I would also need variables to use, let's say crystals they need to use to increase the % of upgrading by XX %.

 

Ty

Link to comment
Share on other sites

  • Solution

Okay so for your percents per level, basically you will want to have a map/table for each of your levels. One way to do this is to just hardcode an array with the percents you want. For example:

 

$percents = array(1=>80,20=2);
I just showed your first and last level as an example; you'd add levels 2-19 with your own values. The benefit if doing it this way is that you have more control over balancing your game.

 

Alternatively, if you just want to do something simple like make it an even(ish) spread, you could automate this with a formula:

 

$percents = array();
$minLevel=1;
$maxLevel=20;
$minPercent=2;
$maxPercent=80;
for ($p=$minLevel;$p<=$maxLevel;$p++) {
  $percentInc = ($maxPercent-$minPercent)/($maxLevel-1);
  $percent = $maxPercent-(($p-1)*$percentInc);
  $percents[$p] = $percent;
}
This will give you an array of percents like this:

 

Array
(
    [1] => 80
    [2] => 75.8947368421
    [3] => 71.7894736842
    [4] => 67.6842105263
    [5] => 63.5789473684
    [6] => 59.4736842105
    [7] => 55.3684210526
    [8] => 51.2631578947
    [9] => 47.1578947368
    [10] => 43.0526315789
    [11] => 38.9473684211
    [12] => 34.8421052632
    [13] => 30.7368421053
    [14] => 26.6315789474
    [15] => 22.5263157895
    [16] => 18.4210526316
    [17] => 14.3157894737
    [18] => 10.2105263158
    [19] => 6.10526315789
    [20] => 2
)
IMO you should prolly throw some rounding into the mix but that's a judgement call you'll have to make.
Link to comment
Share on other sites

Wow, exactly what I was looking for.  That code is very easy to read as well. (I always get lost in foreaches, but this is very simple for me, thank you)

 

I'll be making the lvl 19 lower than 6% chance though just because I want +20 to be end-game material.

 

Marked as solved, didn't know you guys were still active here thank you a lot.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.