I've got a number of Game Variables (all floats) and I'd like, in an event, to make another game variable equal to whatever the highest value is among them. Is there a simple way to do this?
  • Hm, no, there's no easy way, you'd have to go through all the variables in any case. I see 2 possible solutions:

    - go through all variables individually, if the variable is higher, set the new variable to that value and check the next one, of not, check the next one, etc.

    - use a formula that uses the Maximum Value node to with the Current Value of the formula and the individual variables, so one node per variable is needed and will at the end return the highest value
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • option 2 looks like exactly what I was thinking. But I'm having trouble getting it to work properly.

    I've got a basic formula with no settings changed at all. It has 4 nodes added, each are a "Maximum value" node with:
    - Operator "Set"
    - Value 1 is Game Variable with the key of one of the four variables I want to compare with eachother.
    - Value 2 is Current Value.

    Then I'm using a "Formula to Variable" node in the event. Formula is the one I made above. I didn't touch Initial Value, User Combatant, Target Combatant, or Variable origin. Variable Key is set to "Max Points", the variable I want to store the maximum value of the other 4. Operator is set.

    But when I run it Max Points remains 0, even when all other variables are above 0.
  • When using the Formula To Variable node, the used game objects for user and target have to be combatants - i.e. if one of them isn't a combatant, the formula isn't used.
    Alternatively, the Change Game Variables node can also use a formula which automatically uses the player's combatant for calculations.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited October 25
    And that remains true even if the formula doesn't actually call any information from any combatants at all? Like, the variables I'm trying to compare aren't attached to any game objects or combatants and neither is the one I'm trying to set based on the comparison. So what game object should I use for the target combatant? Does it matter as long as there is one?

    EDIT: I'm particularly asking because I haven't added any combatants or game objects to the scene besides the background because this scene is just a large dialogue event. Other scenes have non-dialogue game play but not this scene.
    Post edited by Whatexists on
  • Yes, formulas require combatants to be calculated - it doesn't matter if you're using actual information from a combatant or not.

    I'll look into changing this in future updates, but for the time being, just use the player when calculating the formula. The player doesn't need to be spawned for this.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.