TP -> HP Formula

Hello!


This is a converter TP to HP:


c = a.tp*a.mhp/100.to_i; a.tp = 0; c


The only problem is, it cost at least (1 TP) and of course that mean the formula is "wrong".


I wish to get the missing "1 TP" before the formula. I tried lot of things:


c = a.tp+1*a.mhp/100.to_i; a.tp = 0; c     


c = a.tp+1;a.mhp*a.tp/100.to_i; a.tp = 0; c


a.tp+1 c = a.mhp/100.to_i; a.tp = 0; c


Everything failed with weired result or RGSS Console report.


Thanks in advance !
the formula costs nothing, so I assume that the skill that uses the formula is supposed to cost 1TP?


the problem with your later formulae is that you're ignoring mathematical rules: multiplication takes precedence over addition.


and the second and third tries aren't even regular formulae - please try to learn what you're writing instead of experimenting.


The correct formula is a variant of the first line:


c = (a.tp+1)*a.mhp/100.to_i; a.tp=0;c
Thank you Andar.


I cant belive is what I thought first and dident want to try cause I was thinking it's not like mathematical rule ...


I know the ( ) and [ ] but, but, ... ... bah shame.

please try to learn what you're writing instead of experimenting.

I wish to learn everything and to know the universal knowlwge as life origine, but it is impossible (lack of time 😛 )


I've learned a lot while experimenting stuffs.


Have to be more confident on the first ideas.


Well thanks again
I know the ( ) and [ ] but, but, ... ... bah shame.

If you think those are the same, then you're wrong.


In programming, only () (and only those) are mathematical elements. [] is an array indicator and can't be used unless you want to access an array or an array-based list..
I know it's different.


I forgot the point that the formula is programming and no pure math formula witch means I cant use [ ] in that case, but only for array stuffs.


Learned more than expected today.


Thank you Andar sensei !

Original thread: https://forums.rpgmakerweb.com/threads/tp-hp-formula.63770/