/corescript

Opinionated fork of RPG Maker MV CoreScript, a 2D browser game engine.

Primary LanguageJavaScriptApache License 2.0Apache-2.0

RPG Maker MV CoreScript

Project Introduction

"RPG Maker MV CoreScript" is a game engine for 2D games that runs on the browser. "RPG Maker MV CoreScript" is designed as a game engine dedicated to "RPG Maker MV", the latest work of "RPG Maker" series of 2DRPG world number one software with more than 20 years history, and more than 1000 games are running. (February 2017)

This Fork

This fork introduces opinionated changes and is not necessarily a drop-in replacement for the default RPG Maker MV scripts.

  • Updated to use PIXI v6.5.x and PIXI-Tilemap v3.2.x
  • Uses PIXI equivalents whenever possible instead of the Bitmap object
  • Uses PIXI.BitmapText for fast, memory-efficient text
  • Allows windows to overlap each other
  • Added FPS check to switch on/off fluid timestep
  • Switched to the PIXI.App model
  • Gamestats (performance monitoring plugin) integration

Compatibility Breaks

  • REMOVED: Picture blend modes
  • REMOVED: Picture smooth scaling
  • REMOVED: HTML5Audio
  • REMOVED: Gradients in gauges
  • StorageManager has been renamed and is no longer compatible with plugins that alter saving/loading.
  • NOTE: "Window Color" in the System menu of the editor is now applied differently than the default scripts. The default value of (0, 0, 0) is black. Using pure white (255, 255, 255) will disable it.

Added hooks

  • Added Game_Battler.onApplyDamage(action, target, value)
  • Added Game_Battler.onReceiveDamage(action, source, value)
  • Added Game_Battler.onHitAction(action, target)
  • Added Game_Battler.onEvadeAction(action, source)
  • Added Game_Battler.onApplyStateSuccess(stateId, target)
  • Added Game_Battler.onApplyStateFailure(stateId, target)
  • Added Game_Battler.onApplyCritical(action, target, value)
  • Added Game_Battler.onReceiveCritical(action, source, value)

Split functions into smaller parts

  • Added Game_Action.processItemHitFormula(result, target)
  • Added Game_Action.processItemEvaFormula(result, target)
  • Added Game_Action.processItemCriFormula(result, target)
  • Added Game_Action.processElementalDamage(item, value, target, critical)
  • Added Game_Action.processPhysicalDamage(item, value, target, critical)
  • Added Game_Action.processMagicalDamage(item, value, target, critical)
  • Added Game_Action.processRecoveryDamage(item, value, target, critical)
  • Added Game_Action.processCriticalDamage(item, value, target, critical)
  • Added Game_Action.processVarianceDamage(item, value, target, critical)
  • Added Game_Action.processGuardDamage(item, value, target, critical)
  • Added Game_Action.processDamageEnd(item, value, target, critical)
  • Added BattleManager.processEscapeFormula (Function)
  • Added GameStorageManager.uniqueKey to customize the webkey used for finding matching saved files
  • Added ImageManager._imageExtension to easily customize image extension

Upgrading your project to this fork

  1. Download the /dist folder from this repo.

  2. Move the files into your project's /js folder. Overwrite if prompted.

  3. Open your index.html and delete these script tags:

  • libs/pixi-picture.js
  • libs/fpsmeter.js
  • libs/lz-string.js
  • libs/iphone-inline-video.browser.js
  • rpg_core.js
  • rpg_managers.js
  • rpg_objects.js
  • rpg_scenes.js
  • rpg_sprites.js
  • rpg_windows.js
  1. After pixi.js and before plugins.js, add script tags for these files:
  • libs/comlink.js
  • libs/gamestats.min.js

Constitution

The core script is split into 6 sections.

rpg_core
Wrapper classes of Pixi.js and base classes such as audio and input processing.
rpg_managers
Static classes named XxxManager that manage the game overall.
rpg_objects
Classes named Game_Xxx dealing with game data (many are saved).
rpg_scenes
Classes named Scene_Xxx in which the scene is defined.
rpg_sprites
Classes named Sprite_Xxx related to image display and processing.
rpg_windows
Classes named Window_Xxx handling window display and input.

In addition, a plugin list is defined in plugins.js, and main.js launches the game.

Each part of the engine can loaded as a JS module, or you can use the compiled dist/main.js that includes the full engine.

Global variables

Variables named $dataXxx are read from JSON in the data folder. These files are changed by the editor, but they are immutable during play. Variables named $gameXxx are instances of the class defined in rpg_objects.js. When saving the game, these objects (except $gameTemp, $gameMessage, $gameTroop) are serialized to JSON and saved. When loading, since the prototype chain is reconnected simultaneously with deserialization, you can continue using instance methods.

Scene graph

The scene graph is a drawing tree like FLASH provided by Pixi.js. Children are influenced by parent's coordinates and visibility. Register a child in the form (scene or sprite or window).addChild(child).

Scene

In RMMV the scene is the root element of the scene graph and has children with Sprite and Window. The life cycle is managed by SceneManager, and it operates up to one at the same time.

Life cycle: new Scene_Xxx() -> create() -> start() -> update()* -> stop() -> terminate()

Flow

Initialization

  1. When the page is loaded, call SceneManager.run(). (main.js)
  2. Initialize classes such as Graphics, WebAudio, Input, TouchInput.
  3. Set Scene_Boot to SceneManager.
  4. Register SceneManager.update in requestAnimationFrame.

requestAnimationFrame is called by the browser at regular time intervals (every time drawing is required).

Update

  1. requestAnimationFrame calls SceneManager.update().
  2. Process the current scene every 1/60 second according to the scene lifecycle rule
  3. If Scene_Xxx.update() is called, then
    1. Call all children update().
    2. Children recursively call their children update().
  4. Render the scene (including its children) onto the screen.
  5. Register SceneManager.update in requestAnimationFrame.

Licenses

Main files

Bundled Dependencies

This project tree-shakes and exports its dependencies.