Creating and initializing a combatant in your custom scripts is easy, once you know how.

Creating a combatant via script requires the following steps:

  • creating a group
  • creating the combatant
  • initializing the combatant

Let’s look at those steps in detail.

Creating a group

The Group class holds all combatants that are part of a group (e.g. the player group), the group’s inventory, manages who is fighting and which faction they’re part of.

You can create a new group with the following code:

Group group = new Group(int factionID);
  • int factionID
    The ID/index of the faction the group will be part of.

You can join a combatant to a group (when it’s not already joined to the group through the creation, see below for details) using the following code:

group.Join(Combatant combatant, bool showNotification, bool showConsole);
  • Combatant combatant
    The combatant that will join the group.
  • bool showNotification
    true if notifications should be shown, otherwise false.
  • bool showConsole
    true if notifications should be shown, otherwise false.

Creating a combatant

The Combatant class holds everything related to a combatant – status, equipment, etc.

You can create a new combatant with the following code:

Combatant combatant = ORK.Combatants.Create(
	int combatantID, Group group, bool showNotification, bool showConsole);
  • int combatantID
    The ID/index of the combatant.
  • Group group
    The group the combatant will join.
  • bool showNotification
    true if notifications should be shown, otherwise false.
  • bool showConsole
    true if console lines should be added, otherwise false.

Initializing the combatant

The combatant created earlier has only basic initializations done – we still need to set up the level, class level and class the combatant should have, which will initialize the status, equipment and other things of the combatant. You can either use the default start settings of the combatant’s settings, or define the values you want.

Initializing a combatant with the default start settings:

combatant.Init();

Initializing a combatant with defind level, class level and class:

combatant.Init(int level, int classLevel, int classID, bool loadGame,
	bool learnAbilities, bool useStartInventory, bool useStartEquipment,
	bool useInitEvent, bool useStatusEffects);
  • int level
    The level the combatant will have.
    Has to be at least 1.
  • int classLevel
    The class level the combatant will have.
    Has to be at least 1.
  • int classID
    The ID/index of the class the combatant will have.
  • bool loadGame
    true if this is a creation from loading save game data, otherwise false.
    You usually want to pass on false here.
  • bool learnAbilities
    true if the combatant should learn the set up abilities, otherwise false.
  • bool useStartInventory
    true if the combatant should use the set up start inventory, otherwise false.
  • bool useStartEquipment
    true if the combatant should use the set up start equipment, otherwise false.
  • bool useInitEvent
    true if the combatant should use the set up init game event, otherwise false.
  • bool useStatusEffects
    true if the combatant should check the auto status effects upon creation, otherwise false.

Spawning a combatant

If you want to spawn your newly created combatant, you can use the following code:

combatant.Object.Spawn(Vector3 position, 
	bool setRotation, float yRotation, bool setScale, Vector3 scale);
  • Vector3 position
    The position the combatant will spawn at.
  • bool setRotation
    If you want to set the rotation when spawning or not.
  • float yRotation
    The rotation of the Y-axis when spawning (only used when setRotation is true).
  • bool setScale
    If you want to set the scale when spawning or not.
  • Vector3 scale
    The scale that will be used when spawning (only used when setScale is true).