edited November 2019 in ORK Support
I use the latest 2.27 beta version and I'm trying to display a flying text when I change a status value by code. I use:

combatant.Status[StatusID].AddValue(value, false, false, false, false, true, false, null);


Everything works perfectly, the flying text is displayed with the correct value. However, if I look in the Combatant fields of the inspector, the Status Value is not updated. I made further tests, and it shows that it is updated one frame and then, it reverts to 0, the initial value. I also tried to add a value change event on the Status Value, and it only triggers once, when I change the value. It doesn't trigger when the value is reverted to 0.

When I use AddBaseValue() instead, it works perfectly, but, of course, the flying text doesn't display.

I tried to do the same with a blank scene and it works perfectly, so it must be a problem on my side. Yet, I am quite sure I only try to modify this value at one place in my code... and anyway, the Value Change Event should be triggered more than once if 2 commands were to change the Status Value and it is not.

Any idea about what might cause this issue?
Post edited by ArsMagika on
  • Generally, the inspector isn't updated constantly, so the value it displays might be wrong. Inspectors usually only update on input over them (e.g. mouse click, scroll wheel).

    What type of status value are you changing?
    If it's a Normal type status value, you need to change the base value if you want permanent change.
    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!
  • edited November 2019
    I understand your point about the Inspector's refresh rate, but I don't think it matters in this issue, as even the Debug.Log function says the Status Value is updated one frame and then it is reverted back to its initial value. Also, the Inspector displays the correct value when I use AddBaseValue.

    Concerning permanent change, what do you mean exactly? Right now, as I said, it only changes the Value for one frame. My comprehension of the AddValue function is that it is used to add bonuses or things that can be removed, but not only for one frame!

    As I said, what I find weird is that even a Status Change event does not catch when the Status Value is reverted back.

    Also, it seems to affect every Status Values. I can't change any of them if I use AddValue, but they all work with AddBaseValue.

    Could it be a problem with the parameters of my function? I don't think they are documented and I'm not sure of the use of some of them. In particular, what is the type StatusValueChangeSource? Is it ok to use null instead?

    Could it be the side effect of a Status Effect or an Item? I've checked them all and I don't see anything that could be responsible for that, but maybe you could have an intuition about some setting that could cause my problem...

    I'd completely understand if you can't help me as I fear my problem might be too specific. Anyway, I found a workaround: I simply use both AddValue() and AddBaseValue functions. AddValue changes my status and AddBaseValue does not, but it displays the flying text. Also, note that I CAN add bonuses to Status Values by using Status Effects from the ORK editor. The problem seems to happen only when I use custom code.
    Post edited by ArsMagika on
  • The parameters of your function call are correct and the change source can be null.

    What I meant was that the different types of status values (e.g. normal and consumable) all behave differently and require different functions to update them.
    A Consumable type status value only needs to use the AddValue function.
    A Normal type status value needs to use the AddBaseValue and the AddValue function to be called, because a status update (recalculation of all bonuses) will use the base value + bonuses to set the current value.
    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!
  • Ok. By looking at the source code of the Change Status Value node, I found that, when we use this node to change a Normal Status Value, it uses both AddBaseValue AND AddValue.

    So, you do the same as me, but I'm still not sure I understand why you need to use both functions... I would tend to think that it would add the value twice!

    Could you please explain a bit more?

    Thanks!
  • The reason for this is how Normal type status values work. I'll try to explain this with an example:

    A combatant's ATK (normal type status value) has a current value of 50.
    The value consists of:
    - base value: 30 (e.g. due to the combatant's status development)
    - bonus from equipment: 15
    - bonus from status effect: 5

    Upon a status recalculation (e.g. due to adding or removing a status effect), the status value's current value will be recalculated using the base value and adding all the bonuses (e.g. from equipment, status effects and passive abilities).

    AddValue only changes the current value, which will be reset on the next recalculation.
    AddBaseValue only changes the base value, which doesn't affect the current value until the next recalculation.
    So, if you want to change a Normal type status value, you need to call both functions to have the change be permanent and also affect the current value immediately.
    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! Many thanks!
Sign In or Register to comment.