Upgrade Button Question
Hey Everyone,
So I am trying to create stats like health that upgrade. So all my attributes like health, defense, each weapon damage are all in the game attributes.
Now I have a a gameplay scene and a menu scene where the health upgrade button is.
I have a Health attribute, a Health(Upgrade) attribute and a Health(LevelUp) Attribute.
So the idea is they click the button and it adds .5% to the total life. Everytime the player levels the health would go up by 1000 health.
So what I tried to do was change attribute: game.player1health(upgrade) to: game.player1health(Upgrade) +0.05 when they click a button and have enough money, in one rule.
Then I put change attribute: game.player1health to:game.player1health *game.player1Health(Upgrade) + game.player1health(levelUp)
This doesnt work because it gives me a crazy equation instead of a number. I have tried putting the last equation in the rule and out, it still gives me the same results.
I am guessing its because the equation just keeps running and constantly multiplies the numbers.
(I should add that the reason I have these 3 attributes instead of just saying game.player1health * .05.. is because it would take the current hp and not update the health when the player upgrades)
Does anyone know what is wrong and what I should do instead?
So I am trying to create stats like health that upgrade. So all my attributes like health, defense, each weapon damage are all in the game attributes.
Now I have a a gameplay scene and a menu scene where the health upgrade button is.
I have a Health attribute, a Health(Upgrade) attribute and a Health(LevelUp) Attribute.
So the idea is they click the button and it adds .5% to the total life. Everytime the player levels the health would go up by 1000 health.
So what I tried to do was change attribute: game.player1health(upgrade) to: game.player1health(Upgrade) +0.05 when they click a button and have enough money, in one rule.
Then I put change attribute: game.player1health to:game.player1health *game.player1Health(Upgrade) + game.player1health(levelUp)
This doesnt work because it gives me a crazy equation instead of a number. I have tried putting the last equation in the rule and out, it still gives me the same results.
I am guessing its because the equation just keeps running and constantly multiplies the numbers.
(I should add that the reason I have these 3 attributes instead of just saying game.player1health * .05.. is because it would take the current hp and not update the health when the player upgrades)
Does anyone know what is wrong and what I should do instead?
Answers
The max health starts out at 10,000, then every level up 1000 hp is added. So the upgrade has to upgrade the current hp and the hp thats obtained from level ups after that.
If I just did it this way, if the player upgrades at level 10 at 20k hp, the player would get 1000 more hp. But if the player leveled up, the upgrade wouldnt count the next hp gained from the levels.
Everytime I go to the Upgrade screen, it plays all the rules again so it adds another 10,000 hp.
How or where should I put the logic, so it just updates the game attribute once and doesnt keep adding like it is?