Skip to content

Developer Documentation

Lord Samuel Cardillo edited this page Nov 25, 2019 · 14 revisions

WARNING : This documentation is not finished and therefore not exhaustive. Many things are still missing and what is here is still subject to changes.

Player object

You can access the player object through playerData.

Note :

  • password is not accessible on client-side.
  • permission and id are not stored when client disconnected.
 { 
     id: 'a628687c-c163-4444-a877-035e3be58ee1',
     isBusy: false,
     mapId: 2,
     permission: 100,
     skin:
      { battlerName: 'Actor1_1',
        characterIndex: 0,
        characterName: 'Actor1',
        faceIndex: 0,
        faceName: 'Actor1' },
     stats:
      { hp: 450,
        mp: 90,
        equips: [Array],
        skills: [Array],
        level: 1,
        exp: [Object],
        gold: 0,
        items: {},
        armors: {},
        weapons: {} },
     switches: [Array],
     username: 'someUsername',
     password: 'someHashedPassword'
     x: 13,
     y: 10
  }

Core functions (server-side)

Each core functions can be access through MMO_Core followed by the core part called, example : MMO_Core["database"].

Game data (/core/gamedata.js)

This module is an optional module. It will only load if the correct path is given to it and will populate itself with all the database from the game : maps, events, ... For the moment, it doesn't do anything else than exposing those data but it will be used in the future for NPC movements synchronization, live map editing, ...

MMO_Core["gamedata"].path

Variable containing path to the game. Default : ../../

MMO_Core["gamedata"].loaded

Variable containing stating if the module has loaded successfully or not. Return a Boolean.

MMO_Core["gamedata"].data

Variable containing an object of each data in JSON. Example : MMO_Core["gamedata"].data["Map001"].

MMO_Core["gamedata"].reloadData(callback)

Reload the game files in MMO_Core["gamedata"].data. Callback is returned when finished.

MMO_Core["gamedata"].saveData(dataName)

Save the JSON data back to the file. dataName is a string (example : Map001)

Database (/core/database.js)

MMO_Core["database"].SERVER_CONFIG

Variable containing the server configuration (including offline maps & global switches)

MMO_Core["database"].registerUser({username: "", password: ""}, callback)

Register a user. Function takes an object with username.

Note : If you set passwordRequired to true, the function will expect a password too in the object.

MMO_Core["database"].findUser({username: ""}, callback)

Find a user by its username. Function takes an object with username filled.

MMO_Core["database"].findUserById(userId, callback)

Find a user by its UUID.

MMO_Core["database"].savePlayer(playerData, callback)

Save player. Note : playerData can be WHATEVER, only the username is required. Example, to just put a new level without affecting the rest of the player object : MMO_Core["database"].savePlayer({username: "someUser", stats: {level: 10}})

MMO_Core["database"].reloadConfig(callback)
MMO_Core["database"].saveConfig()

Security (/core/security.js)

MMO_Core["security"].createLog(message)

Create a log in the server. It is based on MMO_Core["security"].debugVerbose.

  • 1 : No logs.
  • 2 : Only logs in the server console.
  • 3 : Logs in server console & .log file.
MMO_Core["security"].hashPassword(password)

Return the password hashed with SHA-256 + SALT (salt can be changed in security.js)

Socket (/core/socket.js)

The socket core integrate modules that can be accessed by .modules, example : MMO_Core["socket].modules["player"]`

The modules can integrate sub modules that can be access by .subs, example : MMO_Core["socket].modules["player"].subs["auth"]`

MMO_Core["socket"].socketConnection

Variable containing the io connection.

MMO_Core["socket"].loadModules(path, isSub);

Load all the modules from a specific path.

Note : isSub should always be equal to true.

MMO_Core["socket"].getConnectedSocket(map (optional));

Return all the connected sockets in a object where keys are socketId. If argument map is given (example: getConnectedSocket("map-2")), only return the sockets from given map.

Socket - Module : player - sub-module : player (/modules/player/player.js)

MMO_Core["socket"].modules["player"].subs["player"].getPlayers(map (optional));

Return all the connected players in a object where keys are username. If argument map is given (example: getPlayers("map-2")), only return the players from given map.

MMO_Core["socket"].modules["player"].subs["player"].refreshData(player);

Refresh the data of the player (playerData) and emit refresh_player_data. player is expected to be the socket object.

Socket - Module : player - sub-module : party (/modules/player/party.js)

MMO_Core["socket"].modules["player"].subs["party"].getPartyLeader(String partyName);

Return the socket object of the party leader (including known playerData).

MMO_Core["socket"].modules["player"].subs["party"].joinParty(Object joiner, Object joinee);

Makes joiner join the party of joinee.

MMO_Core["socket"].modules["player"].subs["party"].leaveParty(Object leaver);

Makes leaver leave a party. Note: If party host, the function disbandParty will be called.

MMO_Core["socket"].modules["player"].subs["party"].disbandParty(String partyName);

Disband a party and eject every players out of it.

MMO_Core["socket"].modules["player"].subs["party"].refreshPartyData(String partyName);

Refresh the data the parties by emitting the socket event refresh_party_data with an Object where keys are usernames and contain the player object of each party members.

Socket - Module : messages (/modules/messages.js)

MMO_Core["socket"].modules["messages"].sendToMap(String map, String username, String message, String senderId (optional));

Send a message to every players on given map (example: map-2). senderId is optional but should be a socketId.

MMO_Core["socket"].modules["messages"].sendToAll(String username, String message);

Send a message to every players on the game.

MMO_Core["socket"].modules["messages"].sendToPlayer(Object player, String username, String message);

Send a message to a specific player (player being the socket object)

MMO_Core["socket"].modules["messages"].sendToParty(String partyName, String username, String message);

Send a message to a specific party.

Core functions (client-side)

WARNING Most of everything below this line is outdated and will not work anymore. The new developer documentation is currently being written. Meanwhile, feel free to ask for support on Discord.

MMO_Core

MMO_Core.socket = Object

Contain the socket connection.

MMO_Core.allowTouch = Boolean

If touch (mobile) is allowed or not. Default is at true. Note: HTML interfaces are unresponsive if at true.

MMO_Core.sendMessage(String) 

Make the client send a text message. Trigger socket new_message.

MMO_Core_Players

MMO_Core_Players.Player 

Contain the player object.

MMO_Core_Players.Players

Contain an array of connected players on the map ordered by socketId. Each object contain the RPG Maker event of the player.

MMO_Core_Players.savePlayerStats()

When called, save current player statistics. (soon to be replaced for anti-cheat)

MMO_Core_Players.getPlayerPos()

Return an object containing current x, y and mapId of the player.

MMO_Core_Players.updateSkin(payload)

Expect argument containing at least type (can be face, battler, sprite). Trigger token player_update_skin.

MMO_Core_Players.refreshPlayerOnMap()

Send a demand to the server to refresh the player to notify changes to other players on the map. Trigger socket refresh_player_on_map.

MMO_Core_Players.updateBusy(newState)

Send a new busy state to the server (ex: combat, menu, ...)

MMO_Core_Players.refreshStats()

Refresh the stats of the player.

MMO_LoginForm

There is no exposed functions for MMO_LoginForm.

MMO_Overhead

There is no exposed functions for MMO_Overhead

MMO_ChatBox

ChatBox.generate()

Generate the chat box.

ChatBox.toggle()

Toggle the chat box.

ChatBox.resize()

Resize the chat box.

Dom events (client-side)

mmorpg_core_lost_connection

Sent by MMO_Core.js in case socket connection is lost.

refresh_player_on_map (payload)

Sent by MMO_Core_Player.js in case a player is refreshed on the map.

Sockets emit (server-side)

new_message(string)
login_success({msg: object})
login_error({msg: string})
map_joined({id: string, playerData: object})
map_exited(string)
player_update_switch({switchId: key, value: boolean})
refresh_players_position(string)
refresh_player_on_map({id: string, playerData: object})
refresh_player_data(object)
player_moving(object)
player_respawn({mapId: integer, x: integer, y: integer})

Sockets emit (client-side)

player_update_skin(object)
refresh_players_position({id: string, playerData: object})
refresh_player_on_map()
player_update_busy(string)
player_update_stats(object)
map_joined(object)
player_moving(object)
player_update_switches(object)
player_global_switch_check({switchId: key, value: boolean})
player_dead()
new_message(string)
login(object)