edited March 2014 in ORK Scripting
Hi Gil,

I have been tinkering with creating a combatant using script. It worked, and I can make the combatant appear in a specific location on a scene.

My questions are:
- how can I create a number of combatants, and then assign them to different parties / player group? So let's say I have created combatants A,B,C,D,E,F. A,B go to group 1, C,D go to group 2, and E,F go to group 3.
- After the groups are all set, how do I make sure that when I save the game (by clicking on the save game menu), all the above combatants info (health, position, etc) and their group configurations are also saved into the savegame file? Will ORK by default recognize all these script generated combatants?

Post edited by gamingislove on
  • Moved to scripting.

    The player groups are managed by the PlayerHandler class - you can access it through:

    ORK.Game.PlayerHandler

    Player groups are identified by an ID - the default group (which is already created at game start) has the ID 0.

    The following function will return you a Group object for an ID, if the group doesn't exist, it'll be created:

    ORK.Game.PlayerHandler.GetGroup(int id);

    You can join combatants to the group, either through their ID (index) or using a combatant object:

    group.Join(int id);
    group.Join(Combatant combatant);


    So, in total:

    Group group = ORK.Game.PlayerHandler.GetGroup(1);
    group.Join(0);
    group.Join(1);
    ...



    You can also do this through the event system - in that case, you'll first need to create a new group using the Create Group step, and switch the active player group to that group using the Change Active Group step.
    After that, you can join combatants using the Join Active Group step.

    All player groups and their combatants will be saved in a save game, it doesn't matter if they're coming from an event or a script, when they're added, they're saved :)
    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 for the reply, Gil.

    I tried with one combatant, and I can spawn him on a specific location.
    However, when I tried to add him to a group, he disappears.

    follow-up question: how do I spawn the new player group at a specific location or to get one of the group members location and use it?
  • The combatant's game object is destroyed when he leaves a battle group - that happens in your case when he joins the new group and leaves his old one.

    You can spawn a new player group by first spawning it's leader and spawning the other members afterwards.

    Spawning a group's leader:

    group.Leader.Spawn(Vector3 position, bool setRotation, float yRotation, bool setScale, Vector3 scale);

    Spawning the rest (battle group only):

    group.SpawnGroup(bool onlyNonCreated);
    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, Gil. The code works now!
Sign In or Register to comment.