Hi,

In my game, I try to make a charge attack ability in a phase-based combat. This ability is available to the player only when his character has moved trough 6 hexes in the last 2 turns. To achieve that, I thought I could use a Status Value Requirement in the charge ability. The status value, named HexesLast2Turns is in fact a combined value using a formula. The formula adds together 2 object variables set on the player combatant's game object: float hexesThisTurn and float hexesPreviousTurn. Then, I use a Turn Start Event (in Battle Settings) in which I set the hexesPreviousTurn to the value of hexesThisTurn and then set hexesThisTurn to 0. Finally, every time I move the character onto a new hex in my "move" battle event, I increment hexesThisTurn by one. In the inspector of my character, under the Object Variable component, I can see that the object variables are properly set.

The thing is, it doesn't work :( The charge ability is never available. I also tried to set the Charge ability requirement to an object variable instead of a Status value, but even then, it never worked even if I could see in the inspector of my game object that the variable was correctly updated and that it met the requirements of the Ability (e.g. variable > 6).

The only way I managed to make it work is the following: I use a Status Value Requirement in the Charge ability. This Status Value is normal, not combined, and does NOT use a formula. Then, every time I change the hexesThisTurn variable, I also use a Change Status Value node. In this node, I specify the Value to equal the result of a Formula (this formula adds hexesThisTurn to hexesPreviousTurn).

So, yes it works, but I'd really appreciate if someone here could give me some hints about why the other, IMO simpler, ways do not work. Why does the formula does not update when I use a combined status value? Why does the ability requirement is never "true" when I use an object variable, even though I know for sure that this object variable meets the criteria of the requirements?

Thanks!
  • The combined status values are not constantly updated, only upon a status recalculation (e.g. when a status value changed), so changing object variables doesn't trigger this.

    You can manually do this using a Reset Combatant Status node, e.g. after each time the object variables changed or at the end of your grid move event.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Got it! I think I will simply replace my Object Variables by hidden status, so when I'll change one of them, the formula will update automatically, without the need of a Reset Combatant Status node.
Sign In or Register to comment.