edited April 2014 in ORK Scripting
Hi,

How to get and set status values for a combatant using script. I made it with game variables, but I think there is more simple way to do it.
Post edited by iglander on
  • First, you'll need to get the actual combatant (if you don't already have it) - see this how-to on this topic.

    After that, it's quite straight forward, you can access a status value of the combatant through:

    combatant.Status[int index]

    Where index is the ID of the status value.

    E.g. Adding a value to the HP (in this example on index 1):

    combatant.Status[1].AddValue(int add, bool isCritical, bool checkDeath, bool checkLevelUp, bool showNotification, bool showConsole);
    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!
  • I tried to do this but I've got this error "null reference" while executing. I set the player in the ORKFramework Editor --> Events --> Set Player and I set my script by the ORK Game Starter Inspector

    player = GameObject.Find("Player");
    Combatant combatant=ComponentHelper.GetCombatant(player);
    Debug.Log(combatant.Status[0])

  • That's not really how it works - Set Player is used to change the player from one combatant to another. To add a player, you need to use the Join Active Group.
    If you haven't done already, I'd suggest to go through the game tutorials to learn using ORK Framework.

    You're getting a null reference error, because either your "Player" object doesn't exist or doesn't have a combatant.
    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, you're right but there was another problem : The argument of GameObject.Find is in fact the name of the gameobject's prefab and ORK adds "(Clone)" at runtime. So, if your prefab is "Brown Pants", you need to pass "Brown Pants(Clone)" as argument of GameObject.Find.

    Thanks a lot for your quick answers and you great job !
  • "The argument of GameObject.Find is in fact the name of the gameobject's prefab and ORK adds "(Clone)" at runtime. So, if your prefab is "Brown Pants", you need to pass "Brown Pants(Clone)" as argument of GameObject.Find."

    Which is the reason why I use this: ORK.Game.ActiveGroup.GetMember(index);
Sign In or Register to comment.