Upgrade Button Question

EricTippettEricTippett Member Posts: 45
edited July 2012 in Working with GS (Mac)
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?

Answers

  • EricTippettEricTippett Member Posts: 45
    Oh, that's what I meant with the 3 attributes. Because the upgrade cant just upgrade the max health, it has to upgrade the Level Up Health and the Max Health both.
    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.
  • EricTippettEricTippett Member Posts: 45
    Oh and another problem that may be contributing to this is..
    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?
Sign In or Register to comment.