So, one of the skills I wanna make in my game is a low-damaging (1d3) skill that, as it's used, raises the user's MAT.
My idea was to use a series of states that raised MAt by 10%, 15%, and 25%, respectively. In theory, the first time the user casts the spell, they would gain the first state. The second time, they would gain the second state and lose the first one, then the third time they would gain the third and lose the second. I tried making a formula to do so, but I'm running into a problem. The skill deals 0 damage every time I use it, and while it does add the second and third states, it doesn't remove any of them. Would someone mind taking a look at my formula and telling me what I've done wrong? (I've cut it to multiple lines to make it easier to read, but in the actual database it's only one line.)
a.isStateAffected(29)? (a.addState(30) && a.removeState(29) && (Math.randomInt(3) + 1 + ((a.mat - 10) * 0.5))) :
a.isStateAffected(28)? (a.addState(29) && a.removeState(28) && (Math.randomInt(3) + 1 + ((a.mat - 10) * 0.5))) :
(a.addState(28) && Math.randomInt(3) + 1 + ((a.mat - 10) * 0.5))
When I look at it, the way it reads to me is "If the user is affected by state 29 (the tier 2 state), add state 30 to the user (tier 3) AND remove state 29 from the user AND deal (0 to 2, plus 1, plus half of the user's MAT stat above 10) damage. If not, if the user is affected by state 28 (tier 1), add state 29 to the user AND remove state 28 from the user AND deal damage. If not, add state 28 to the user AND deal damage." This is obviously not how the program reads it, though. Any idea where I went wrong? Thanks!
My idea was to use a series of states that raised MAt by 10%, 15%, and 25%, respectively. In theory, the first time the user casts the spell, they would gain the first state. The second time, they would gain the second state and lose the first one, then the third time they would gain the third and lose the second. I tried making a formula to do so, but I'm running into a problem. The skill deals 0 damage every time I use it, and while it does add the second and third states, it doesn't remove any of them. Would someone mind taking a look at my formula and telling me what I've done wrong? (I've cut it to multiple lines to make it easier to read, but in the actual database it's only one line.)
a.isStateAffected(29)? (a.addState(30) && a.removeState(29) && (Math.randomInt(3) + 1 + ((a.mat - 10) * 0.5))) :
a.isStateAffected(28)? (a.addState(29) && a.removeState(28) && (Math.randomInt(3) + 1 + ((a.mat - 10) * 0.5))) :
(a.addState(28) && Math.randomInt(3) + 1 + ((a.mat - 10) * 0.5))
When I look at it, the way it reads to me is "If the user is affected by state 29 (the tier 2 state), add state 30 to the user (tier 3) AND remove state 29 from the user AND deal (0 to 2, plus 1, plus half of the user's MAT stat above 10) damage. If not, if the user is affected by state 28 (tier 1), add state 29 to the user AND remove state 28 from the user AND deal damage. If not, add state 28 to the user AND deal damage." This is obviously not how the program reads it, though. Any idea where I went wrong? Thanks!