edited August 27 in ORK Scripting
Hello,

I am encountering this error when running this code. I want to add experience to an ability via code. It seems that this error occurs whenever I attempt to use my AbilityShortcut object. For example, ability.GetName(); also triggers the error.

public void TriggerAbilityExp() {
...
Combatant player = ORK.Game.ActiveGroup.Leader;
AbilityShortcut ability = player.Abilities.Get(abilityGuids[Maki.Game.Variables.GetString(currentRecipeTypeVar)]);
ability.LevelPoints;
...
}
Method call failed (GamingIsLove.ORKFramework.GetCraftCollection): TriggerAbilityExp Exception has been thrown by the target of an invocation.
Post edited by Neziak on
  • edited August 29
    The Get function of the combatant's abilities doesn't use the GUID of the ability from the settings, but a unique GUID for that combatant instance. The inventory works the same way (and some other parts) - basically having a GUID for instances.

    Insetad, you need to get the ability's settings using it's GUID and use that to get the ability instance. Use this code to get the ability:
    AbilityShortcut ability = player.Abilities.Get(ORK.Abilities.Get(abilityGuids[Maki.Game.Variables.GetString(currentRecipeTypeVar)]));

    Also, some null checks might be a good idea to make sure no error occurs :)
    Post edited by gamingislove on
    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!
Sign In or Register to comment.