Jump to content
  • Advertisement
Sign in to follow this  

Scalable Combat Formulas (Python)

This topic is 3803 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am working on the formulas for an RPG game and I have one started. It seems to scale fine for the first 10-15 levels, but after that it gets unfair. If any of you have some extra time, I would love some help modifying or even redoing a good formula for a fair combat system. My game is being tested based on 50 levels, but I might cap it at 100. I'm using Attack Points and Defense Points. If the attacker's AP > DP, then he wins. The only multipliers are gear points and personality/class. A defensive class gets 1% bonus to DP. An offensive class gets 1% bonus to AP. I want someone who is a couple of levels lower, with good gear, to stand a chance against someone of a higher level with mediocre gear. For example: A level 35 with level 35 gear should stand a chance against a level 37 with level 34 gear. I hope that covers everything, here's the formulas I've been testing: Points=(30L*(L/5))+rand(L,(L+10))+(20L)+B L = level, B = Gear Points + Class Bonus Gear points = item level * 20 Class Bonus = 1% of AP or DP (after gear is applied). Of course, if someone has a mixture of lvl 7 and lvl 8 gear, it would be a float of 7-8 and so on. Here is the code I'm using for testing combat simulations (using Python). It simulated 100 battles and gives the # of wins:
import random

La=50 #Attacker's level
Ld=50 #Defender's level
Ga=50 #Attacker's Gear level
Gd=50 #Defender's Gear level
Ga = Ga * 20 #Attacker's Gear Points
Gd = Gd * 20 #Defender's Gear Points

WLAVG = 0  #Win/Lose Average

for i in range(1,101):
        AP1 = (((La*30) * (La/5)) + random.randrange(La, (La+10)) + (La*20) + Ga)
        DP1 = (((Ld*30) * (Ld/5)) + random.randrange(Ld, (Ld+10)) + (Ld*20) + Gd)
        DP1 = DP1 + (DP1 * 0.01)
        if AP1 > DP1:
                WLAVG += 1
print WLAVG,"% Wins"

So if anyone can fix my formula to scale better. I couldn't find any good formulas online that would work with my game, so I'm just doing it from scratch.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!