I've done some searching and found the posts to create a combatant this way:


Combatant combatant = ORK.Combatants.Create(
int combatantID, Group group);

My code is as follows:

Group group = new Group(2);
int index = 2;

Combatant combatant = ORK.Combatants.Create(index, group, true, true);
Debug.Log(combatant);

--When I run this the debug reads "Null" - does this mean a new combatant hasn't been created? Also, if I don't include the 2 bools in the Create() part like how it shows to do this in the example posts, I can't get the script to compile. Any ideas on what I'm doing wrong here? Thanks!
  • ORK's API sometimes changes as features are added, so some older posts might not be 100% accurate any longer.

    This is currently the correct way to create a combatant, but don't forget to also initialize it (via the Init() function):
    Combatant combatant = ORK.Combatants.Create(index, group, true, true);
    combatant.Init();


    If the combatant is null, that's most likely due to using an index of a not yet defined combatant. E.g. if you only have 1 or 2 combatants set up, index 2 will try to use the 3rd combatant, which doesn't exist.
    The index is the ID/index of the combatant in the editor, i.e. the number you can see in front of the combatant's name in the list.
    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!
  • Thanks! I had misunderstood and thought that create meant creating a brand new combatant as opposed to creating a combatant that already has an index set up in the framework.

    I was wanting to set up a series of randomly generated character stats and then if the player chooses a given one, then to create the combatant with those stats.

    Would the correct approach be to set up a combatant with index 1 and then create as many of those as needed, and then for each created one adjust the stats and visuals as needed on each individually? If so is there a way to save the reference to a given created combatant so I can access that through script?
  • Yes, best approach for this is having a combatant setup used as basis and change the combatant's stats, abilities and other things in-game as needed. Most of this can also be done via the event system, so you don't really have to do it via scripting (but you can).

    There's also the Status Value Distribution menu screen to allow players to distribute status values, can e.g. be used in your start event as a one-time thing if it should only be done for the initial character creation.
    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!
  • Thanks! If I were to create combatants with an event, how would I then reference a given combatant in a script?
  • Depends on how you created them - e.g. if they're spawned, you can get them via their game object.

    A somewhat complex but also the easiest way (without having to get any object references or anyhing) would be using selected data. You can store the combatant into global selected data in the event (e.g. via Select Combatant node) and access that via scripting:
    Combatant combatant = SelectedDataHelper.GetFirstCombatant(ORK.Game.SelectedData.Get("key"));
    You can also store multiple combatants into the same key and get them all:
    List<Combatant> combatants = SelectedDataHelper.GetCombatants(ORK.Game.SelectedData.Get("key"));
    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!
  • Thanks, I think I am understanding better in reading more, one thing I'm currently struggling with is how in the events to refer to a combatant I've created (but not spawned) through script. My code to create the combatant is:
    Group group = new Group(0);
    int index = 0;
    Combatant combatant = ORK.Combatants.Create (index, group, true, true);
    combatant.Init();
    ORK.GlobalEvents.Get(4).Call();
    I'm trying to pick up the new combatant in the global event I call at the end of the code above. I've been playing around with 'Select Combatant', 'Set Player' but don't seem to be intended for this use.
  • edited 10:53AM
    If you use this function, you can pass on the combatant as the event's starting object (even without having it spawned), i.e. you can add a Starting Object actor to the event to access it via that:
    ORK.GlobalEvents.CallGlobalEvent(index, combatant);
    index is the ID/index of the global event, combatant your combatant :)

    Otherwise, you can store it into global selected data and access it wherever needed:
    ORK.Game.SelectedData.Change("key", combatant, ListChangeType.Set);
    You can also add it via ListChangeType.Add, remove it, etc.
    Post edited by gamingislove at
    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.