Coin Drop Equation

When you kill a player in swordbattle, you get coins. Everybody knows this. But sometimes, it just doesn’t seem like you got enough coins. I know that if there were no limit, the game would lag when a player with lots of coins died, and it would be really OP, so I came up with a new xp equation. The current one works like this, you get 80% of the player’s coins, clamped between 10 and 20,000, so you never get more than 20k.
Current Equation:

var dropAmount = clamp(Math.round(thePlayer.coins*0.8), 10, 20000);

Now my solution was to use a logarithmic function so that it still increases, but not too fast. The highest anyone could realistically get using this equation is 85k, which is still a considerable amount more. It uses the same equation that is in the game except it doesn’t cap at 20k. After 20k it switches to the logarithmic function, and the slope begins to flatten out faster.
New Equation:

var dropAmount = thePlayer.coins < 13 ? 10 : Math.round(thePlayer.coins < 25000 ? thePlayer.coins * 0.8 : Math.log10(thePlayer.coins) * 30000 - 111938.2002602);

I’ve tested it and it seems to work fine. You should just be able to replace the old line of code with this new one to implement it. Maybe try it for a day or so and if it needs tweaking I can change it for you. Lastly, I have included a nice graph and a link to it to show what it will look like. The green line shows the old equation and the blue line shows the new one. The purple line is just y=x for a reference. The function should NEVER go above y=x. To hide a line just click on the colored circle next to its equation.
Here is the link:

5 Likes

will be added, thanks for providing the code also, makes it easy for me :D

4 Likes

What do you mean? 1 million will drop around 68k.
image

3 Likes

Btw this is what the game is using currently, and it’s working great!

8 Likes

I didn’t know bread could code

3 Likes

He’s just chill like that :sunglasses:

3 Likes

Yes he could he is super good at it
HIS coding name is sharkcoding

3 Likes

I found out about swordbattle through replit.com

3 Likes

me too

3 Likes

Bread is smort

4 Likes

Not the first thing which comes to mind when i think of bread.
:thinking:

2 Likes

Stoobid

1 Like

I tink of ze tasty cheese toastie

1 Like

Bread is tasty thats the first thing that comes to mind

I think of food.

1 Like

I love bread (both food and person)

5 Likes

Bread is a staple of perfection on what food should be able to do