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:

  • 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:

  • Combatant combatant
    The combatant that will join the group.

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:

  • int combatantID
    The ID/index of the combatant.
  • Group group
    The group the combatant will join.

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:

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

  • 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.

Spawning a combatant

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

  • 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).