While poking around with VX Ace's base scripts, I figured a way that I could make effects from features add together instead of being multiplicative—for example, two "120%" features would total 140%, not 144%. I did this by going into Game_BattlerBase and taking this method:
def features_pi(code, id)
features_with_id(code, id).inject(1.0) {|r, ft| r *= ft.value }
end
...and creating this alternate method which I use in place of "features_pi" for the standard parameters:
def features_xsum(code, id)
features_with_id(code, id).inject(1.0) {|r, ft| r += (ft.value - 1) }
end
I tested this with an actor with 100 in ATK and DEF, plus three different equipment items that each have difference ATK and DEF features but no static increases to the parameters. And from my testing, the method I create does seem to properly result in the parameter features having an additive effect...except for some reason, sometimes it's 1 point off from what it should be.
The three test items I'm using are a weapon with "DEF * 90%", clothes with "DEF * 110%", and a shield with "DEF * 125%". With all three together, the actor has 125 DEF (100 - 10% + 10% + 25%). If I remove the weapon, their DEF becomes 135 as it should be. Most combinations of the three items give the proper value, but if I equip the weapon with the shield, the DEF displayed is 114 when it should be 115 (100 - 10% + 25%). Doubling the actor's ATK and DEF still results in the DEF being one point lower (229) than it should be (200 - 10% + 25% = 230) when the weapon and shield equipped.
What could be causing this problem, and how would I correct it?