To prevent any computation issue and save processing power, we could use an array that contains computed values like this one (blue formula rounded to nearest integer, C code):
Code: Select all
const int DamageBonus[256]={0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,6,6,7,7,8,8,9,10,10,11,12,12,13,14,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,35,36,37,38,40,41,42,44,45,46,48,49,50,52,53,55,56,58,59,61,62,64,66,67,69,71,72,74,76,77,79,81,83,85,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,117,119,121,123,125,128,130,132,135,137,139,142,144,146,149,151,154,156,159,161,164,166,169,172,174,177,180,182,185,188,190,193,196,199,202,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,250,253,256,259,262,266,269,272,276,279,282,286,289,292,296,299,303,306,310,313,317,320,324,328,331,335,339,342,346,350,353,357,361,365,369,372,376,380,384,388,392,396,400,404,408,412,416,420,424,428,433,437,441,445,449,454,458,462,467,471,475,480,484,488,493,497,502,506,511,515,520,524,529,534,538,543,548,552,557,562,566,571,576,581,586,590,595,600,605,610,615,620,625,630,635,640,645,650};
When we need the damage bonus value that corresponds to a dexterity or strength, we simply use:
As dexterity and strength share the same formula, we only need one DamageBonus array. In my small game projects I would typically make this array a global variable and add a lower case g at the beginning of its name: gDamageBonus.
The new implementation aims to benefit the new players that ignore the "you need a multiple of 10 to benefit from your character points investment" from the old formula.