Skip to content
On this page

Actors

Prerequisites

Read the article Create database to find out how to put the data into your game and then use it.

Full Actor

ts
import { RpgPlayer, Presets } from '@rpgjs/server'
import { Fighter } from 'my-database/classes/fighter' // Remember to put a correct import
import { Actor } from '@rpgjs/database'

const { MAXHP } = Presets

@Actor({  
    name: 'Hero',
    description: 'A great fighter!',
    initialLevel: 1,
    finalLevel: 99,
    expCurve: {
        basis: 30,
        extra: 20,
        accelerationA: 30,
        accelerationB: 30
    },
    parameters: {
        [MAXHP]: {
            start: 700,
            end: 10000
        }
    },
    startingEquipment: [],
    class: Fighter 
})
export class Hero {
    onSet(player: RpgPlayer) {
        
    }
}

API


parameters

  • Property: parameters
  • Type: object
  • Optional: true
  • Arguments:
    • {object} ``. (Optional: false)
  • Usage:

Give parameters. Give a start value and an end value. The start value will be set to the level set at initialLevel and the end value will be linked to the level set at finalLevel.

ts
import { Presets } from '@rpgjs/server'

const { MAXHP } = Presets 

parameters: {
     [MAXHP]: {
         start: 700,
         end: 10000
     }
}

startingEquipment

Allows to give a default equipment

ts
import { Sword } from 'my-database/weapons/sword'

startingEquipment: [Sword]

class

  • Property: class
  • Type: ClassClass
  • Optional: true
  • Usage:

Assigns a default class

ts
import { Fighter } from 'my-database/classes/fighter'

class: Fighter

Set initial level

  • Property: initialLevel
  • Type: number
  • Optional: true
  • Usage:

Set final level

  • Property: finalLevel
  • Type: number
  • Optional: true
  • Usage:

Experience Curve

  • Property: expCurve
  • Type: object
  • Optional: true
  • Usage:

With Object-based syntax, you can use following options:

  • basis: number
  • extra: number
  • accelerationA: number
  • accelerationB: number

id

  • Property: id
  • Type: string
  • Optional: true
  • Usage:

The id of the item. The identifier makes it possible to find an object in the database. By default, the identifier is the name of the class


name

  • Property: name
  • Type: string
  • Optional: true
  • Usage:

The name of the item.


description

  • Property: description
  • Type: string
  • Optional: true
  • Usage:

The description of the item.


statesEfficiency

WARNING

The realization of this property or method has not been completed.

  • Enum: number
TagDescription
  • Property: statesEfficiency
  • Type: Array<{ rate: number, element: StateClass} | StateClass>
  • Optional: true
  • Example:

Example 1

ts
import { Paralyze } from 'my-database/states/paralyze'

statesEfficiency: [Paralyze] // rate is 1 by default

Example 2

ts
import { Paralyze } from 'my-database/states/paralyze'

statesEfficiency: [{ rate: 1.5, state: Paralyze }]

Example 3 (todo)

ts
import { Efficiency } from '@rpgjs/server'
import { Paralyze } from 'my-database/states/paralyze'

statesEfficiency: [{ rate: Efficiency.VULNERABLE, state: Paralyze }]
  • Usage:

List of states.

Changes the efficiency of the states. It indicates whether or not the player with a class or state will be vulnerable to the state. It is a multiplying coefficient for damage calculations.

To help, you can use the Efficiency enumerations


elementsEfficiency

  • Enum: number
TagDescription
Efficiency.GAIN_HP-0.5 value
Efficiency.PERFECT_INVULNERABLE0 value
Efficiency.INVULNERABLE0.5 value
Efficiency.NORMAL1 value
Efficiency.VULNERABLE1.5 value
Efficiency.VERY_VULNERABLE2 value
  • Property: elementsEfficiency
  • Type: Array<{ rate: number, element: Element} | Element>
  • Optional: true
  • Example:

Example 1

ts
import { Element } from 'my-database/elements'

elementsEfficiency: [Element.Fire] // rate is 1 by default

Example 2

ts
import { Element } from 'my-database/elements'

elementsEfficiency: [{ rate: 1.5, element: Element.Fire }]

Example 3

ts
import { Efficiency } from '@rpgjs/server'
import { Element } from 'my-database/elements'

elementsEfficiency: [{ rate: Efficiency.VULNERABLE, element: Element.Fire }]
  • Usage:

List of elements.

Changes the efficiency of the elements. It indicates whether or not the player with a class or state will be vulnerable to the element. It is a multiplying coefficient for damage calculations.

To help, you can use the Efficiency enumerations