I've run into a problem juggling variables in my combat system, which its burning a hole in my brain.
I was wondering if any of you guys could give me some advice on how to handle something like this?
let me explain it a little, ill try to keep it short and simple (if i can);
1. Combat is based on "Effective Stats" which are calculated by "Base Stats" + "Boosted Stats"
2.You gain an obj/ability which is controlled by the hud and when used equips an obj/item on your character, what this item does is call a proc that works differently based on that item name, which changes on player choice and they cant change it while boosted.
3. Depending on what that item name is your "Boosted Stats" will be different.
3. You can spend points while boosted to upgrade your "Base Stats", here is where the issue starts.
The issue i'm having is that way I made it handle the variables, when the proc first runs it takes at that time the "Base Stats" and calculates what to add to the "Boosted Stats" however, you can change your "Base Stats" while you are still boosted and when it goes to remove the "Boosted Stats" It can remove way too much.
stat changes are calculated by doing the opposite of what the boost does which is;
usr.BoostedStats += usr.BaseStats * 2 //This is boosting the stats
usr.BoostedStats -= usr.BaseStats * 2 //This is what deboosting the stats
If the base stats have changed, when you go to deboost the value will be different from when you boosted. Making it cut away at another boost you have on or shave away all of the "Boosted Stats" value.
Not sure if i'm thinking about it too much, but the only soloution I could come up with is to make a ton a new tmp variables. Which I want to try and avoid.
How would any of you handle something like this?
Thanks in advance! (Sorry for the wall of text :(, i tried to shorten it. I really did!)
Really I'm opposed to stats in general because I feel like they create stale gameplay. You're just looking for the things with the highest numbers. If you balance around base skills/effects I feel like it creates a nice environment.
As for your question itself, I personally never add stats like that. If you want to to stick to that, you should find a way to always add/subtract the same amount. Always add by the base stat
So if something added 10% of your damage and you had 100 damage
100 + 0.1 * 100 = 110
(or if you prefer, 11/10 * 100 = 110)
But wait, you leveled up and got 20 damage. Now you have to refresh your stats to make sure they're added properly
RefreshStat()
Now your stats are:
120 + 0.1 * 120 = 132
(120 * 11/10 = 132)
Okay, your buff ran out. Run the reciprocal of 11/10 on it (or 10/11)
132 * 10/11 = 120
All you need is to understand fractions. Boom.
EDIT: May want to make sure you utilize floor/ceil functions so you always get integers. I think there's a snippet which forces integer functions.