edited August 2015 in ORK Scripting
probably not but i figured id ask is there a function i can call from the start function to get a update on when a status value changes? kinda like the equipment function you gave me.. trying to reduce resources an was hopping there was a way to do this...
Post edited by wtyson on
new website can be found here http://www.fore-loregames.com

Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

or check out the face book page here https://www.facebook.com/ForeLoreGames
  • There are update events to register to (like with the equip stuff) for pretty much all of those things - that's how ORK handles stuff internally to reduce performance costs :)

    You can register a function to each status value of a combatant to be notified when the value changed. The function should look like this:

    public void StatusValueChanged(Combatant combatant, int id, int change)

    id is the index/ID of the status value, change is the change that happened.

    combatant.Status[statusID].Changed += StatusValueChanged;

    And don't forget to unregister again (e.g. when using in a component, in the OnDestroy function):

    combatant.Status[int statusID].Changed -= StatusValueChanged;
    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!
  • just to make sure im reading you right on this one


    public void StatusValueChanged(Combatant combatant, int id, int change)

    Change equals the amount that changed or the result? so lets say i had 100 hp an it went down to 99 that int would cover the 1 point change or the actual result of 99.. sorry usually do this on update instead of a custom function so trying to under stand....
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • The change is the actual change - if you're using the Real Value Count setting, it'll also be fired with 0 change each frame while the value is faded.
    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 ty
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • any chance i can get a example of this plz

    combatant.Status[statusID].Changed += StatusValueChanged;


    status id i under stand but you say changed is the changed that happened is this referring to a variable that i set or something else?
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • Changed is the value the status value was actually changed by (through whatever method you're using). E.g. if you add 100, the change is 100, if you set it to 1 and it was previously 50, the change is -49.
    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!
  • oh basically im just trying to get the changes from ork without using void update () so if i lose hp id want to get that change ....
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • That's what I showed you is there for, just implement the function in your script, register it to your HP status value and you'll get notified each time the HP changes - if you only want to react to losing HP, make a check for change < 0.
    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 August 2015
    and id have to make a function for every status value? That id want a get the values for?
    Post edited by wtyson on
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • For every status value you want to get notified by.
    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 thank you !
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • edited August 2015
    combatant.Status[int statusID].Changed -= StatusValueChanged;

    when put into a ondestroy it just toss me errors an never gets read


    even Combatant.Status[0].Changed -= StatusValueChanged;

    dont work either



    this is not really needed but would be nice just in case.

    the first part works great was able to implement my pain hud thanks to this little function ^^..


    also the change only shows the damage and or the numerical value that was used to change the status values. it dosent actually allow you to use this to update your status values if your getting the value so you can see the change in real time. unless you got a way to do this so that it will.

    unless i should be doing this call int he custom function as well


    if (combatantComponent != null) {
    Combatant combatant = combatantComponent.combatant;

    currentHealth = combatant.Status [0].GetValue ();
    maxHealth = combatant.Status [1].GetValue ();
    }


    if this is the case then i can use it this way if you can confirm this that be great..
    Post edited by wtyson on
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • You need to check your code - e.g. combatant.Status[int statusID] can't work, neithe will Combatant.Status[0] if your combatant is written with a lower case c in your code.

    The registered function is called after the status value has changed, not to change the status value. If you want to change your status value, just use the functions for that, e.g. AddValue.
    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 August 2015
    combatant.Status[int statusID].Changed -= StatusValueChanged;

    the above code is a code snippet you gave me... even replacing the statusid with 0 does not work when used in a on destory function




    and your not seeming to under stand what im trying to do...

    void Update() {
    CombatantComponent combatantComponent = playerCharacter.
    GetComponent<CombatantComponent> ();
    if (combatantComponent != null) {
    Combatant combatant = combatantComponent.combatant;
    //Ammo Counts
    currentPistolAmmo = combatant.Status [11].GetValue ();

    }


    as of now is how i get the status value from ork every frame im wondering if i can use this function except separated so id only be calling one value per function i have to make .. so something like this ....
    void Start {
    CombatantComponent combatantComponent = playerCharacter.
    GetComponent<CombatantComponent> ();
    if (combatantComponent != null) {
    Combatant combatant = combatantComponent.combatant;
    combatant.Status[11].Changed += StatusValueChanged;
    }

    }

    public void StatusValueChanged(Combatant combatant, int id, int change){
    id = 11;
    currentPistolAmmo = combatant.Status [11].GetValue ();


    }



    would this work in the same way? im not in the office so i cant test atm just trying to get a idea before i go in tomorrow... im trying to get my GetValue's off update to reduce performance issues..

    i have a feeling it will but cant test atm :P
    Post edited by wtyson on
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • edited August 2015
    ok got this working for the add but not the on destroy that still is not working at all
    Post edited by wtyson on
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
Sign In or Register to comment.