edited April 2014 in ORK Scripting
Hi Gil,

could you point me to a way to designate a combatant group as the active player group? I know there is a way using the event system, but I would prefer to do it using script.

This function will be useful in the situation where there are for example 5 friendly combatant groups on the map and the player want to cycle between them.
  • There isn't a function to make an already existing group to a player group - you'll either have to add one yourself in the PlayerHandler class, or join the combatants of those groups to a player group.
    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!
  • is the PlayerHandler class exposed when I import the ORK Framework package into a project?

    Alternatively, if I create a new script to do this, would the steps be like this:
    - create an array of combatants - c1, to save the current active group combatants
    - create a variable as reference to the active group - g1

    - create an array of combatants c2, to save the second group combatants
    - create a variable as reference to the second group - g2

    - remove all members from g1
    - get all combatants from c2, and add them to g1

    - remove all members from g2
    - get all combatants from c1, and add them to g2

    - set g1 location to one of its combatants

    - set g2 location to one of its combatants


    Would this work?
  • You can access the class through ORK.Game.PlayerHandler in a running game. The class is also part of the gameplay code, so it can be altered in the full version.

    I've already explained in your other thread how you can access different player groups in the PlayerHandler. So it'd be way easier if you simply add a new player group and use that group when creating your combatants - they'll automatically join the group you've used.

    To switch between player groups, you can use this function:
    ORK.Game.PlayerHandler.SetActiveGroup(int id);
    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!
  • Hi Gil,

    thanks for the reply.

    If I follow that approach, what will happen to the original player group? Is it deleted automatically, since it will no longer have members? If it is deleted, will the player group indexes be re-arranged automatically as well?

    Also, when I create the new group, I need to use an id that has not been used before right?
    The way I get the new id for now is by looking into the ork framework option and manually assign the (last index + 1) as the new index. Is there a way for me to get the last player group index or to get the total count of how many player groups are there?

    Sorry if I overlooked a simpler solution that you have mentioned before.
  • No, the groups will still be there, even without members - but if you remove the members, they'll be gone ...

    The player groups aren't index based - but ID based, so, you can have groups with the IDs 0, 1, 5 and 20. There is no function to get the last/highest ID, but you can check if an ID already exists by calling ORK.Game.PlayerHandler.GroupExists(int id).
    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!
  • Is there a way to get the ID of a particular player group?
  • No, you'll have to make a function for that yourself.
    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!
  • Okay. I somehow managed to add a function inside the PlayerHandler class to switch groups according to my requirements, based on our discussion.

    Thanks for the help, Gil.
  • I'll try to add some functions in the next update as well, so that you can use the built-in stuff without the need to add your code on every update :)
    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. That would be great :)
  • Hey Gil, did you ever add this functionality to the event system?

    I'd like to let the player cycle through friendly combatant groups just like @andyMul was talking about. I see the Change Active Group step, but it removes the old group from the scene, so it's not really "cycling" through groups.
  • There's now the ReplaceGroup(int id, Group newGroup) function available that can be used to exchange groups.
    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.