RPG Question

drekryan

First Post
Hey I created a rpg/text based game and I have been struggling on one concept. I need help getting together a formula for battle experience. I have a formula for experience needed to level up but my current battle exp forumla is randomized too much. I want it so you get more experience for killing players higher level than you and more experience the higher the damage and based on your level a bit as it takes more exp to level as you get higher level. Any simple formulas that you can think of that may be able to help would be great. I cant find any good help on this anywhere
 

log in or register to remove this ad


Ok so I have a text based game where players duel other players for experience and money. I need a new experience formula because mine is currently ($exp = (rand(5,7) * $user['Level'])) but it is too random. I want a formula to calculate experience each time i attack them. I want it so that you get more experience for attacking someone higher level than you and/or if you deal more damage than them. Damage is constant based on your stats. The damage I would deal to a player would be my attack minus their defense and their damage towards me would be their attack minus my defense. Players regenerate 5 hp every 5 minutes and they tend to hit them when they only have 5 hp so damage based exp would be great. I only want positive numbers for experience. I tried something like (damage you deal to them - damage they dealt to you) / 1.25 but the experience is too low because if I dealt the max damage possible which is one hundred when they are at full health it would be (100-0)/1.25 which is only 80 exp where as for a level 50 it should be about 300-400 exp per duel. Im not so good with formulas so im not sure where to go with this but i dont want the formula to be too randomized. Let me know if there if info you need that I left out.

For those that dont know PHP rand (5,7) mean random number between 5 and 7.
 

What do you want the experience range to be at first level?

You could do something like ((damage dealt-received)+rand(50))*(level/15)

That would give you a maximum range (ie dealing 100 damage and receiving 0) of 7-10 xp at level 1 and a max range of 337-500 xp at 50th.

It's strange to me that you're adding the random element to experience instead of damage. Is there a reason why? Are you just trying to take the die rolling out of the players hands? If so, there are other ways that you can do that.
 

What do you want the experience range to be at first level?

You could do something like ((damage dealt-received)+rand(50))*(level/15)

That would give you a maximum range (ie dealing 100 damage and receiving 0) of 7-10 xp at level 1 and a max range of 337-500 xp at 50th.

It's strange to me that you're adding the random element to experience instead of damage. Is there a reason why? Are you just trying to take the die rolling out of the players hands? If so, there are other ways that you can do that.
At first I wanted experience to vary a little that's why I used a random number but now I just want it based on level and/or damage. The formula you came up with is great as it gives perfect experience rates for the correct level but there is on problem and that is with negative experience. For example if I take say 44 damage and deal 0 the formula would calculate it out to -255 experience. I dont want negative experience but I do want a lower experience rate for when they deal higher damage than you.
 

At first I wanted experience to vary a little that's why I used a random number but now I just want it based on level and/or damage. The formula you came up with is great as it gives perfect experience rates for the correct level but there is on problem and that is with negative experience. For example if I take say 44 damage and deal 0 the formula would calculate it out to -255 experience. I dont want negative experience but I do want a lower experience rate for when they deal higher damage than you.

Ah, I was imagining that losing a duel meant that you were dead.

You could have it that the loser gets half the XP amount that the winner got; though that makes it so that you learn more by throwing in the towel, than you would by putting up a good fight.

Can the loser gains XP from a different formula? What kind of rewards do you want for losing? Are players' levels going to be different, and should that be factored into the math somewhere?
 
Last edited:

Ah, I was imagining that losing a duel meant that you were dead.

You could have it that the loser gets half the XP amount that the winner got; though that makes it so that you learn more by throwing in the towel, than you would by putting up a good fight.

Can the loser gains XP from a different formula? What kind of rewards do you want for losing? Are players' levels going to be different, and should that be factored into the math somewhere?
Two formulas would be fine I could use the one above for when they win but is there a formula that could give positive experience for losing just a lower amount? The only thing to factor in is the level as it becomes harder to level as you level up. The formula for calculating the experience needed for the next level is ceil((100 * ($user['level'] * $user['level']))) * (1.79 + ($user['level'] / 10))). The ceil function just rounds numbers up to the nearest whole number so for level one the experience needed to reach level two would be 189 and for level 50 to level 51 it would be 1697500. There are raids as well that users can set for a certain time limit. The longer you wait on the raid the more experience and money the player gets so there are other ways of getting experience other than dueling/attacking other players. I think I just need a formula to calculate experience if you lose (deal less damage then they deal to you.
 

The only thing to factor in is the level as it becomes harder to level as you level up.

No, I mean: should a level 1 guy get more experience for beating someone who is level 5, than a level 4 guy gets for beating the same level 5 someone?

Contrary-wise, does a level 50 guy have anything to gain from mopping up a room full of level 1 guys?
 

No, I mean: should a level 1 guy get more experience for beating someone who is level 5, than a level 4 guy gets for beating the same level 5 someone?

Contrary-wise, does a level 50 guy have anything to gain from mopping up a room full of level 1 guys?
They should get higher experience rates for attacking someone higher level then them and maybe like half the experience for attacking lower level players.
 

Remove ads

Top