Detecting when an attribute changes - STILL NEED HELP PLEASE!

JagonAppsJagonApps Member Posts: 241
edited August 2013 in Working with GS (Mac)
I know this topic has been brought up once before, but at the time there were no viable answers...
So I would like to find out the easiest way for an actor to detect when an attribute changes and then act on that change, eg. in a rule.
In the past to get around this I have stored the last attribute recorded in another attribute and then just updated it with the next last when the attribute changes. This is both inefficient, and when I want to act for example after 5 changes to the attribute, I think I would have to have 5 separate attributes and rules all connecting with each other to achieve this.

Are there any other workarounds?

Many thanks

Max

Best Answers

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,922
    Accepted Answer
    Looking at what you've got there isn't going to be a magic bullet E=MC2 type equation. You're going to have to break the things you want into blocks with a control function. So an attribute the when say it's 4 it tells the other blocks how to react. So basically find the things you can group under a common functions and go from your main attribute and translate that to the execution function of the other blocks. So say for scale 4 could equal a 20% increase 5 could equal 25 et.. Then for your spawn rate 4 could equal -20 time and 5 could equal -25 et... So I hope you get my logic here. So you have to basically build a translation code for all the blocks that trigger based on the one attribute.
  • tenrdrmertenrdrmer Posts: 9,934
    Accepted Answer
    Well number 3 you would probably just need a counter that tracks up to the 5th level number and reset it to 0 either when its achieved or failed

    and number 4 sounds like a simple timer. unfortunately I don't remember if GS has re enabled the ability of the timer to change values on the fly. it was an option at one time but an update a while back killed it.

    I agree with FBS though. there is not going to be a magic formula that does all of this for you. I'm not sure why you think having the code broken up into a bunch of rules is going to be inefficient. its very common to have rules built to cover all the possibilities you want to cover in your game.

Answers

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @JagonApps

    Hi Max, I think I understand what you're asking: basically, that's one use of the Constrain Attribute behaviour, which can constrain a certain attribute to another which will be updated constantly. THen that way, when the constrained attribute is used, for instance in a Rule like "When suchandsuch attribute is > ??" it'll use the most up-to-date attribute value there is. Did that make sense?
  • JagonAppsJagonApps Member Posts: 241
    edited August 2013
    @gyroscope
    //EDITED//
    Thanks for the reply!
    Err..Yer I think so, sorry I didn't say it exactly right, so my idea was to keep the next attribute to be used stored until the attribute.value changes again, so this is what I came up with, but it is still both inefficient and I don't know how to work it to change after 5 changes in attribute, instead of just 1 as shown here.

    1. When attribute.stored = 0 --> change to attribute.value (1)
    -attribute.stored now=1
    2. When attribute.value DOES NOT EQUAL attribute.stored --> NEW LEVEL (SO PERFORM ACTIONS)
    -attribute.stored=1, attribute.value now=2
    3. Change attribute.stored to attribute.value
    -attribute.stored now=2

    Any help would be very much appreciated!
    Cheers
    Max
  • JagonAppsJagonApps Member Posts: 241
    Bumping...
  • JagonAppsJagonApps Member Posts: 241
    Bump-I am still having an issue with this as stated above. Thanks
  • BananarchyBananarchy Member Posts: 11
    edited August 2013
    Use any, all or else to trigger behaviors after calling attributes in a rule or 'sets' of attributes in a rule. Use timers to turn different behaviors on and off and change attributes relative to each other based on the value of the individual attributes that you want to interact. Basically create your own seperate in game logic.

    Remember though the attributes have to be assigned first to your prototype of the instance actor. So an integer or text would work fine.

    I dunno if that helps. Im still working on how to time different in game events based on other events but I'm at work right now. Ill try to think about it some more and maybe have a better answer later.
  • JagonAppsJagonApps Member Posts: 241
    @Bananarchy, thanks for the reply.

    So I think what you are saying is to use timers and other different 'decide' like events to trigger my attribute changes? So what I need a specific way to achieve this with my situation: (trigger attribute changes after a certain amount of levels). My way by recording past levels is ok but seems inefficient and so would you have any specific ways of telling when a level attribute changes after a certain amount of times?

    Thanks
    Max
  • BananarchyBananarchy Member Posts: 11
    edited August 2013
    @Bananarchy, thanks for the reply.

    So what I need a specific way to achieve this with my situation: (trigger attribute changes after a certain amount of levels).

    Hey. Do you have an integar attribute called 'levelcount' that increases incrementally by 1 every time the level changes?

    Might look like this in a rule:


    Change Attribute .. game.levelcount
    .. +1
  • JagonAppsJagonApps Member Posts: 241
    @Bananarchy Yes, I do :P
  • BananarchyBananarchy Member Posts: 11
    So you have a collision event inside a scene that triggers a new level but only when a certian condition is met, which in this case I'm guessing is a collision count, and you want to change the level when the collision count attribute meets a certian criteria?
  • BananarchyBananarchy Member Posts: 11
    edited August 2013
    By the way this thread has been marked answered. ;) In the forum.
  • JagonAppsJagonApps Member Posts: 241
    edited August 2013
    @Bananarchy Yep its a collision count! So I already have a set-up and working attribute which +1 to level every time the collision reaches a certain amount. The thing I want is to have a clever way of an actor to detect when the level attribute has changed.

    One difference is simple enough, but when I have multiple changes, say something happens when the level has changed 5 times, it is harder.

    Ideally I would like a solution which does not restrain me from using an attribute that changes with a set amount each time and that is pre-determined, like the +1 of a level, but instead a random real number, for example that cannot be predicted.


    If you get that! No worries if you don't have any solutions, I certainly haven't thought of a good one that can be used with any non-pre determined change in attribute.

    Max
  • BananarchyBananarchy Member Posts: 11
    edited August 2013
    "Ideally I would like a solution which does not restrain me".
    Or constrain you :) I think your solution is something like a global variable that is constantly updated due to the actor collisions and other attributes.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    it seems like your trying to hard to conceal what your actually trying to accomplish. Not the underlying function but what the game is actually doing. From your descriptions I have no real idea of what the function you are trying to accomplish is. Which means most people are probably gonna need better description of what you are doing to help us visualize a way to accomplish it.
  • ericzingelerericzingeler Member Posts: 334
    I agree with @tenrdrmer, not sure what you're trying to do here.
  • JagonAppsJagonApps Member Posts: 241
    @tenrdrmer
    Really? Sorry. I will explain it better, as so far I have just been trying to achieve one part of my overall desire, of which I am partially there:

    I am looking to create a sliding-like scale of difficulty (with increasing difficulty) as my game progresses by changing attributes such as an actor's size which affects the difficulty.

    -I would like this increase to be endless in possibility (ideally).
    -I would ideally like a clever equation that can be easily edited and with minimal code..
    -Here are the examples of the situations in which I want the difficulty to be changed, along with the best solutions I currently have to fix them:


    1. Having an increasing number of enemies spawning in the scene, after every level has been completed.
    eg. When level increased by 1 --> change game.minimum spawn time --> by -10
    --I think that would work!

    2. By changing the percentage size of the actor, so that it is relative to other attributes eg. size.width and size.height
    eg. When level increased by 1 --> increase size of actor by 10%
    --I think that would work!

    3. A way of changing the increment, eg. an increase in 5 levels, rather than just 1.
    eg. When level increased by 5 --> increase size of actor by 10%
    --Don't have solution to above

    4. A way of increasing an actor's position change
    eg. Every (attribute multiplier?) secs --> change position to rand. (x,x)
    --Don't have solution to above
  • JagonAppsJagonApps Member Posts: 241
    I guess I didn't want to say all this before because in the past people have just seen all the things I want to achieve and, quite understandably, have found it hard to help when problems are not broken down :s
  • ericzingelerericzingeler Member Posts: 334
    Do what @FryingBaconStudios mentioned.

  • BananarchyBananarchy Member Posts: 11
    8-} Still wondering why this post is marked answered.

    And who marked it...?? :-?

    My goodness, what a giant MYSTERY.

  • JagonAppsJagonApps Member Posts: 241
    Ok guys, thank you very much for all your help from you all, those solutions are certainly viable and I better get to work making them work :P

    Cheers
    Max
Sign In or Register to comment.