# AI ChangeLog

# Version 3.0.2

  • maxFps:
    The maximum number of fps for the rendering
  • serverFps:
    Put the number of FPS that the server processes. It allows to synchronize the client rendering with the server. The default value is 60

# Version 3.0.0-beta.9

  • props: Set custom properties on the player. Several interests:
  1. The property is shared with the client
  2. If you save with player.save(), the property will be saved to be reloaded later
  3. If you use horizontal scaling, the property will be kept in memory if the player changes the map and this map is on another server

Example:

import { RpgPlayerHooks } from '@rpgjs/server'

declare module '@rpgjs/server' {
 export interface RpgPlayer {
     nbWood: number
 }
}

export const player: RpgPlayerHooks = {
 props: {
     nbWood: Number
 }
}

This is a simple example. Let's say that the player can have a number of harvested woods, then

  1. you must specify the type for Typescript
  2. Add the property in props

You can also set up with this object:

 {
     $default: <any> (undefined by default), 
     $syncWithClient: <boolean> (true by default),
     $permanent: <boolean> (true by default)
 }
  • Indicate if the property should be shared with the client

Example:

export const player: RpgPlayerHooks = {
 props: {
     secretProp: {
         $syncWithClient: false
     }
 }
}
  • Indicate if the property should be registered in a database. If the data is just temporary to use on the current map:
export const player: RpgPlayerHooks = {
 props: {
     tmpProp: {
         $permanent: false
     }
 }
}

# Version 3.0.0-beta.8

Maximum maps in world: 500

Note, that if the map already exists (i.e. you have already defined an RpgMap), the world will retrieve the already existing map. Otherwise it will create a new map

Note, that if the map already exists (i.e. you have already defined an RpgMap), the world will retrieve the already existing map. Otherwise it will create a new map

# Version 3.0.0-beta.7

# Version 3.0.0-beta.5

If you don't specify the players as parameters, it will display the GUI of the instance But you can specify which GUIs to display by specifying the players as the first parameter

# Version 3.0.0-beta.4

@EventData({
 name: 'EV-1'
})
class MyEvent extends RpgEvent {
 onAction() {
     console.log('ok')
 }
} 

player.createDynamicEvent({
     x: 100,
     y: 100,
     event: MyEvent
})

You can also put an array of objects to create several events at once

Recovers all the colliding tiles of the current player

Recovers all the colliding tiles of the current player

Recovers all other players and events colliding with the current player's hitbox

Recovers all other players and events colliding with the current player's hitbox

  • Get Tile: Retrieves a tile and checks if the player has a collision
const tileInfo = player.getTile(20, 30)
console.log(tileInfo)

Example of returns:

 {
     tiles: [
         {
             id: 0,
             terrain: [],
             probability: null,
             properties: [Object],
             animations: [],
             objectGroups: [],
             image: null,
             gid: 1
         }
     ],
     hasCollision: false,
     isOverlay: undefined,
     objectGroups: [],
     isClimbable: undefined,
     tileIndex: 93
 }
  • Get Tile: Retrieves a tile and checks if the player has a collision
const tileInfo = player.getTile(20, 30)
console.log(tileInfo)

Example of returns:

 {
     tiles: [
         {
             id: 0,
             terrain: [],
             probability: null,
             properties: [Object],
             animations: [],
             objectGroups: [],
             image: null,
             gid: 1
         }
     ],
     hasCollision: false,
     isOverlay: undefined,
     objectGroups: [],
     isClimbable: undefined,
     tileIndex: 93
 }

Since version 3.0.0-beta.8, you can just pass the path to the file. The identifier will then be the name of the file

@EventData({
 name: 'EV-1'
})
class MyEvent extends RpgEvent {
 onAction() {
     console.log('ok')
 }
} 

map.createDynamicEvent({
     x: 100,
     y: 100,
     event: MyEvent
})

You can also put an array of objects to create several events at once

# Version 3.0.0-beta.3

Object:

  • (number) x: Position X
  • (number) y: Position Y
  • (number) width: Width
  • (number) height: Height
  • (object) properties (optionnal):
    • (number) z: Position Z
    • (hexadecimal) color: Color (shared with client)
    • (boolean) collision
    • You can your own properties
  • Attach Shape: Attach a shape to the player (and allow interaction with it)
import { ShapePositioning } from '@rpgjs/server'

player.attachShape({
     width: 100,
     height: 100,
     positioning: ShapePositioning.Center
})

# Version 3.0.0-alpha.9

  • Play Sound: Allows to play a sound, heard only by the player or by the players of the map

Here is a sound, client side:

import { Sound } from '@rpgjs/client'
@Sound({
     id: 'town-music',
     sound: require('./sound/town.ogg')
})
export class TownMusic {}

Here is the call of the method, server side:

player.playSound('town-music')

If you want everyone to listen to the sound on the map:

player.playSound('town-music', true)