Skip to content

Instantly share code, notes, and snippets.

@cornman0101
Created June 2, 2016 09:51
Show Gist options
  • Save cornman0101/2003e014cb1e328203301ee30a5ab9b7 to your computer and use it in GitHub Desktop.
Save cornman0101/2003e014cb1e328203301ee30a5ab9b7 to your computer and use it in GitHub Desktop.
macros for destiny infusion calculator
void statFinal(int defense_initial, int stat_initial, int stat_min_max[2],int defense_final);
float fitValue(int defense);
void statFinal(int defense_initial, int stat_initial, int stat_min_max[2], int defense_final=335)
{
stat_min_max[0] = floor((stat_initial+1.0)*fitValue(defense_final)/fitValue(defense_initial)); //max
stat_min_max[1] = floor((stat_initial)*fitValue(defense_final)/fitValue(defense_initial)); //min
};
float fitValue(int defense)
{
if(defense>300)
return(0.2546*defense-23.825);
if(defense>200)
return(0.1801*defense-1.4612);
else
return(-1);
}
int statFinalMax(int defense_initial, int stat_initial,int defense_final);
int statFinalMin(int defense_initial, int stat_initial,int defense_final);
float fitValue(int defense);
int statFinalMax(int defense_initial, int stat_initial,int defense_final=335)
{
return(floor((stat_initial+1.0)*fitValue(defense_final)/fitValue(defense_initial)));
};
int statFinalMin(int defense_initial, int stat_initial,int defense_final=335)
{
return(floor((stat_initial)*fitValue(defense_final)/fitValue(defense_initial)));
};
float fitValue(int defense)
{
if(defense>300)
return(0.2546*defense-23.825);
if(defense>200)
return(0.1801*defense-1.4612);
else
return(-1);
}
@cornman0101
Copy link
Author

Lightweight should be slightly faster but the user could cause a memory leak if the user doesn't know how to safely pass by reference.

Safe should be fine for most people use cases.

There's a third option which I didn't include, basically, if you'll be making multiple calls (maybe 100?) to this for many armor pieces at the same time, it's better to drop the function "fitValue()" and replace it by loading into memory an array with the fit values for each defense. Then you replace the calls "fitValue(defense_final)" with fitValue[defense -199](details depend on array size). It requires an somewhat more advanced user. If someone doesn't know how to implement this safely and thinks they could benefit, leave a comment.

@mplaner
Copy link

mplaner commented Jun 4, 2016

Ruby version here with percentage calculation and bonus stat values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment