edited February 2018 in ORK Support
Hey, i`m starting over in Ork, and old project I had on RPG Maker ( yeah, upping my knowledge).
I have been messing around with battle events, but have not been able to redo one of my most important mechanics.
I have a skill, called draw, that is supposed to cast one of my learned skills at random.
On my javascript days I created an array that read all the skills I had equipped, did a math.random and picked one from the array index. Ez.
I want to re-do that using events, but have not been able to find a way.

I suppose I need a way to store all skills available, and then cast one at random. I have tried some stuff, but have not achieved how to create a random pick from ALL my skills.

sorry about the bad english, and if anyone have a n idea, I would appreciate ^.^
Post edited by Limonada on
  • edited February 2018
    Hey there, I recreated my javascript code on C# in unity, but I have no idea how to assign my newfound skills to the hotbar I created on my combatant Ui:


    List<AbilityShortcut> drawSkills = new List<AbilityShortcut>();

    Combatant combatant = ComponentHelper.GetCombatant(gameObject);
    List<AbilityShortcut> abilities = combatant.Abilities.GetAbilities(UseableIn.Battle, IncludeCheckType.Yes);


    for(int i=0;i<=3; i++){
    int pick = UnityEngine.Random.Range(0, abilities.Count );
    int pickId;
    drawSkills.Add(abilities[pick]);
    pickId = drawSkills[pick].ID;
    // Add ability id to the hotbar


    }





    Anyone have made it and can give me a hand? Also, It's trhowing me an error about:

    List<AbilityShortcut> abilities = combatant.Abilities.GetAbilities(UseableIn.Both, IncludeCheckType.No);

    NullReferenceException: Object reference not set to an instance of an object

    can't see why there is a null exception, by any means the abilities are not instantiated alongside with the prefab?
    Post edited by Limonada on
  • Well if you don't have too many skills, one way to do it within ORK is to use a random node, and to each branch you attach a use ability node with the skill you want to use. If you have hundreds of skills I'm sure you could hack a little script with a loop.
  • edited February 2018
    @UserName It's a bit more complicated, I have 15 Equipment slots that add skills (Cards), and every turn I have to roll and pick 3 of these abilities, and the player can cast only one of these 3. Pretty much like a card game.

    The only think missing is how I do attach a skill to the hotbar via script. I'm Reading documentation, but still can't find it. Since my C# is limited I fear I'm lacking an example.
    Post edited by Limonada on
  • Got My script writing onto the shortcuts!
    But now and then I get an exception :

    Method Call Failed (Draw): DrawSkills.
    Exception has benn thrown by the target of an invocation


    I have no idea what that means. The times it happens, my iteration won't go, it stops on the first loop.
  • edited February 2018
    Just passing by to tell that it's solved. 'll let my thinking process here to help others.

    The paradigm:

    I need to emulate a Deck, the player have 15 card slots, and he can have a lot more cards than he can equip, so he need to be able to swap cards on his deck. To realize a quick prototype I did not create the deck function, I create 15 new gear slots named cards, and weapon types named cards. Said weapons have an ability equip function, that equip the same ability as the card's name. So far everything working on ORK.

    on the combat the player cannot choose his skills, he must use a class skill named DRAW, and this skill is supposed to go over the entire array of equipped skills, choose 3 unique skills at random and present the possibility for the player to cast any of the 3. these 3 skills are the player's "hand of cards".

    II took off the abilities menu in that actor battle menu, and I created a Shortcut bar to receive the 3 draw skills.

    For this part on the draw skill I realizes I would have to script, so I created an event on the draw skill to call a script called Draw, that contains the method DrawSkill.

    Beware, I`m a graphic designer that know very little about C#, but here is my solution:

    public void DrawSkills() {

    System.Random rnd = new System.Random ();
    List<AbilityShortcut> drawSkills = new List<AbilityShortcut>();
    Combatant combatant = ComponentHelper.GetCombatant(player);
    List<AbilityShortcut> abilities = combatant.Abilities.GetAbilities(UseableIn.Battle, IncludeCheckType.No);
    abilities.RemoveAll(item => item == null);
    //Debug.Log("antes do for");
    int pick;
    for(int i=0;i<=2; i++){
    do{
    pick = rnd.Next(1, abilities.Count );
    //Debug.Log(pick);
    //Debug.Log("carta "+i+" draw");
    }while (drawSkills.Contains(abilities[pick]));
    drawSkills.Add(abilities[pick]);
    combatant.Shortcuts.Current[i]= drawSkills[i];

    }

    }

    }


    Post edited by Limonada on
Sign In or Register to comment.