Last active
August 2, 2019 19:15
-
-
Save kylemsguy/3a1cae9c1c15b8115efe657109c29055 to your computer and use it in GitHub Desktop.
Main Power Up calculator Python script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import json | |
import math | |
def calc_dmg(A, base_dmg, high, mid): | |
_min = 1.0 | |
B = (3.3 * A - 0.027 * A**2) / 100 | |
C = (mid - _min) / (high - _min) | |
D = _min + (high - _min) * lerpN(B, C) | |
return base_dmg * D | |
def lerpN(B, C): | |
if C == 0.5 or B == 0.0 or B == 1.0: | |
return B | |
else: | |
return math.e**(-(math.log(B) * math.log(C)) / math.log(2)) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Calculate the MPU boosted damage of a weapon ') | |
parser.add_argument( | |
'-a', '--ap', | |
type=int, | |
help="Number of Ability Points (Main = 10, Sub = 3)", | |
) | |
parser.add_argument( | |
'-m', '--mains', | |
type=int, | |
help="Number of Mains", | |
) | |
parser.add_argument( | |
'-s', '--subs', | |
type=int, | |
help="Number of Subs", | |
) | |
parser.add_argument( | |
'weapon', | |
help="The ID of a weapon specified in stats.json", | |
) | |
args = parser.parse_args() | |
if args.ap and (args.mains or args.subs): | |
print("Please only specify ability points in one way") | |
exit(1) | |
elif args.ap: | |
A = args.ap | |
else: | |
mains = args.mains * 10 if args.mains is not None else 0 | |
subs = args.subs * 3 if args.subs is not None else 0 | |
A = mains + subs | |
with open('stats.json') as stats_file: | |
# Stats taken from http://leanny.github.io/splat2new/parameters.html | |
stats = json.load(stats_file) | |
curr_stats = stats[args.weapon] | |
result = calc_dmg(A, **curr_stats) | |
print(result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ssp": { | |
"mid": 1.104, | |
"high": 1.208, | |
"base_dmg": 42 | |
}, | |
"96gal": { | |
"mid": 1.125, | |
"high": 1.25, | |
"base_dmg": 62 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment