RPG kinda game problem

Hi! I am creating a game, but I ran into a little problem. I try to explain this as clear as possible. I use example attributes just to make it clearer.

So, let's say I have created attribute "randomTEST" in which I have set rule: every 1 second change attribute "randomTEST"to random(1,150)/100.

I have also attributes "Attack" with a value of 80 and attribute "Defense" with a value of 70. I have also attribute "SCORE" which is displayed in an actor inside my scene.

I've set the rule: When "Attack" is > "randomTEST"*"Defense", then Change attribute "SCORE" to "SCORE"+1

The score works fine when "randomTEST"*"Defense" gives smaller number than "Attack" BUT if the "randomTEST"*Defense is smaller than "Attack" again IMMEDIATELY after that, it won't add score+1. So basically it won't work unless the "randomTEST"*"Defense" becomes greater than "Attack" and only after that it works.. So, I want it to add 1 to score everytime the "Attack" becomes greater than "randomTEST"*Defense.

I don't know if I explained it well and clear enough, I can try to provide more information if needed, but if someone knows how to fix this I would be really thankfull.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're coming up against a common misunderstanding about the way rule conditions work. You're assuming that the rule condition "When a>b, do C" will trigger every time a>b. But this isn't the case. Rules only trigger when the condition changes from being false to true (or is initially true at game start).

    You'll need another attribute, most likely a boolean to force the rule to be evaluated again. So after the attack is over, you reset the boolean (e.g. game.readyToAttack) to true and then place the rule you posted above inside of the rule When game.readyToAttack is true. I believe that will work.
  • machetemachete Member Posts: 8
    edited May 2013
    You're coming up against a common misunderstanding about the way rule conditions work. You're assuming that the rule condition "When a>b, do C" will trigger every time a>b. But this isn't the case. Rules only trigger when the condition changes from being false to true (or is initially true at game start).

    You'll need another attribute, most likely a boolean to force the rule to be evaluated again. So after the attack is over, you reset the boolean (e.g. game.readyToAttack) to true and then place the rule you posted above inside of the rule When game.readyToAttack is true. I believe that will work.
    Oh yes, thank you, just got it work because of your help. I'm pretty new to Gamesalad but as cliche as it sounds, I'm learning new stuff every day and becoming better and better. :)
  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    @machete I've been using GS for about a year now and I'm still learning stuff about it! ;)
  • machetemachete Member Posts: 8
    @Utveckla_Games I can believe that! :) Isn't that one of the nicest things in game development? ;)
  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    @machete Haha it truly is. :D It is good to learn new things though! Otherwise you would never get anywhere or do anything other than what you already knew!
Sign In or Register to comment.