### Install Native Modules with nw-gyp (Shell) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This sequence of shell commands outlines the process for globally installing `nw-gyp` and then using it to build native Node.js modules for NW.js. It includes setting environment variables for target version, architecture, runtime, and build configuration, along with specifying Python paths for Windows. ```shell # Global installation of nw-gyp npm install -g nw-gyp # Set target NW.js version set npm_config_target=0.31.4 # Set build architecture (ia32 or x64) set npm_config_arch=x64 # Set runtime to node-webkit set npm_config_runtime=node-webkit # Enable building from source set npm_config_build_from_source=true # Specify the nw-gyp executable path set npm_config_node_gyp=C:\Users\NALA\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js # For Windows 10, set the Python path: set PYTHON=C:\Users\NALA\.windows-build-tools\python27\python.exe # Install with VS version (e.g., 2015). Retry if compilation fails, delete package-lock.json. npm install --msvs_version=2015 ``` -------------------------------- ### NW.js Configuration Patterns Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Examples of package.json configuration fields for NW.js applications. ```JSON "main": "index.html" := :// := '*' | 'http' | 'https' | 'file' | 'ftp' := '*' | '*.' + := '/' ``` -------------------------------- ### Start Map Event (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Initiates the execution of a specific map event. '1' is the ID of the event to start. ```javascript $gameMap.event(1).start(); ``` -------------------------------- ### Initialize Real-time Battle System UI (JavaScript) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Initializes the UI for the real-time battle system by first loading the necessary CSS styles and then creating the UI elements. This function should be called early in the game's setup. ```javascript RealtimeBattleSystem.UIInit = function () { RealtimeBattleSystem.loadCSS()//加载UI样式 RealtimeBattleSystem.creatUI()//创建UI } ``` -------------------------------- ### Access and Manipulate Clipboard with NW.js Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Provides examples of how to interact with the system clipboard using NW.js. It covers retrieving the clipboard object, reading text data from it, setting text data to it, and clearing its contents. Ensure NW.js environment is available. ```javascript // 获取系统中剪贴板对象 var clipboard = nw.Clipboard.get(); // 剪贴板中读取信息 var text = clipboard.get('text'); console.log(text); // 向剪贴板写入 clipboard.set('I love NW.js :)', 'text'); // 清空剪贴板 clipboard.clear(); ``` -------------------------------- ### Get Current NW.js Window Instance (JavaScript) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html These JavaScript snippets show two equivalent ways to get the current NW.js window object using the `nw.gui.Window.get()` and `nw.Window.get()` methods. The window object is a singleton instance. ```javascript var win = require('nw.gui').Window.get(); ``` ```javascript var win2 = nw.Window.get(); ``` -------------------------------- ### Show Battle Animation (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Plays a visual animation on a specific enemy during battle. 'enemyIndex' is the enemy's index, 'animationId' is the ID of the animation, 'true/false' determines if it's a target animation, and 'delayN' is the delay before the animation starts. ```javascript $gameTroop.members()[enemyIndex].startAnimation(animationId, true/false, delayN); ``` -------------------------------- ### Global Object Access in NW.js Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Illustrates how to access and modify global JavaScript objects within the NW.js environment. This snippet shows a basic example of assigning a value to a global variable. ```javascript global.a =1; ``` -------------------------------- ### C# to JavaScript Interaction in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This snippet shows how to call JavaScript functions from C# in an RPG Maker MV project. It uses the DllImport attribute to import functions defined in JavaScript (.jslib files). The example covers calling basic functions, passing strings, arrays, and handling return values. ```csharp using System.Runtime.InteropServices; [DllImport("__Internal")] private static extern void Hello(); [DllImport("__Internal")] private static extern void HelloString(string str); [DllImport("__Internal")] private static extern void PrintFloatArray(float[] array, int size); [DllImport("__Internal")] private static extern int AddNumbers(int x, int y); [DllImport("__Internal")] private static extern string StringReturnValueFunction(); [DllImport("__Internal")] private static extern void BindWebGLTexture(int texture); void Start() { Hello(); HelloString("This is a string."); float[] myArray = new float[10]; PrintFloatArray(myArray, myArray.Length); int result = AddNumbers(5, 7); Debug.Log(result); Debug.Log(StringReturnValueFunction()); var texture = new Texture2D(0, 0, TextureFormat.ARGB32, false); BindWebGLTexture((int)texture.GetNativeTexturePtr()); } ``` -------------------------------- ### Configure Menu Command Handlers Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Demonstrates how to initialize a command window and bind specific menu actions to scene methods using setHandler in Scene_Menu. ```javascript Scene_Menu.prototype.createCommandWindow = function () { this._commandWindow = new Window_MenuCommand(0, 0); this._commandWindow.setHandler('item', this.commandItem.bind(this)); this._commandWindow.setHandler('skill', this.commandPersonal.bind(this)); this._commandWindow.setHandler('equip', this.commandPersonal.bind(this)); this._commandWindow.setHandler('status', this.commandPersonal.bind(this)); this._commandWindow.setHandler('formation', this.commandFormation.bind(this)); this._commandWindow.setHandler('options', this.commandOptions.bind(this)); this._commandWindow.setHandler('save', this.commandSave.bind(this)); this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this)); this._commandWindow.setHandler('cancel', this.popScene.bind(this)); this._commandWindow.setHandler('test', this.commandTest.bind(this)); this.addWindow(this._commandWindow); }; ``` -------------------------------- ### Get Actor Information in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves a specific actor from the game using their ID. Actor IDs start from 1. This is fundamental for modifying or querying individual character data. ```javascript $gameActors.actor(1) ``` -------------------------------- ### Get Specific Map Event by ID (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves a specific map event object using its unique ID. Event IDs can be found in the editor. IDs start from 1. ```javascript $gameMap.event(1); ``` -------------------------------- ### Realtime Battle System Initialization and UI Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Initializes the battle system environment, including window management and DOM-based UI construction for displaying player stats and equipment status. ```JavaScript var RealtimeBattleSystem = RealtimeBattleSystem || {}; RealtimeBattleSystem.init = function () { nw.Window.get().maximize(); this.attack = true; this._callbackQueue = []; RealtimeBattleSystem.enemyInit(); RealtimeBattleSystem.bindUpdate(); RealtimeBattleSystem.UIInit(); }; RealtimeBattleSystem.getWeapon = function () { let weapon = $dataWeapons[$gameParty.leader()._equips[0]._itemId]; return weapon ? weapon.name : '空手'; }; RealtimeBattleSystem.creatUI = function () { var stateBar = document.createElement('div'); stateBar.classList += "state-bar"; var hpBar = document.createElement('div'); hpBar.id = "hp-bar"; var mpBar = document.createElement('div'); mpBar.id = "mp-bar"; var defBar = document.createElement('div'); defBar.id = "def-bar"; var atkBar = document.createElement('div'); atkBar.id = "atk-bar"; stateBar.appendChild(hpBar); stateBar.appendChild(mpBar); stateBar.appendChild(defBar); stateBar.appendChild(atkBar); document.body.appendChild(stateBar); var equipBar = document.createElement('div'); equipBar.classList += "equip-bar"; var weaponBar = document.createElement('div'); weaponBar.innerHTML = `手持:${RealtimeBattleSystem.getWeapon()}`; equipBar.appendChild(weaponBar); document.body.appendChild(equipBar); }; ``` -------------------------------- ### Create Custom UI Windows Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Provides a template for creating custom windows by inheriting from Window_Base. Includes steps for initialization, defining dimensions, and adding the window to a scene. ```javascript (function () { function CustomWindow() { this.initialize.apply(this, arguments); } CustomWindow.prototype = Object.create(Window_Base.prototype); CustomWindow.prototype.constructor = CustomWindow; CustomWindow.prototype.initialize = function () { Window_Base.prototype.initialize.call(this, 0, 0, 240, 120); this.drawText('Hello World', 0, 0, 200); }; Scene_Menu.prototype.createStatusWindow = function () { this._statusWindow = new CustomWindow(); this.addWindow(this._statusWindow); }; })(); ``` -------------------------------- ### Create Custom Help Window in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This code defines a custom help window that inherits from `Window_Base`. It includes methods to initialize the window's position and size, and a `setInfo` method to display text content. This window can be used to provide contextual information within custom menus or scenes. ```javascript function 自定义HELP(){ this.initialize.apply(this, arguments); } 自定义HELP.prototype = Object.create(Window_Base.prototype); 自定义HELP.prototype.constructor = 自定义HELP; 自定义HELP.prototype.initialize = function () { var x = 250; var y = 0; var width = 500; var height = this.fittingHeight(2);//行宽 Window_Base.prototype.initialize.call(this, x, y, width, height); this._text = ''; } //窗口类的核心方法,自定义代码就在这里写 自定义HELP.prototype.setInfo = function(text){ this.contents.clear(); this._text =text; this.drawTextEx(this._text, this.textPadding(), 0); } ``` -------------------------------- ### Get Mouse Position (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves the current X and Y coordinates of the mouse cursor on the screen. ```javascript TouchInput.x ``` ```javascript TouchInput.y ``` -------------------------------- ### Package NW.js Application Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Command to bundle the game files into an executable using the NW.js runtime. ```batch copy /b nw.exe+app.nw app.exe ``` -------------------------------- ### Get All Map Events (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves a collection of all event objects currently present on the map. ```javascript $gameMap.events() ``` -------------------------------- ### Get Enemy Names (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves an array containing the names of all enemies currently in the troop. ```javascript $gameTroop.enemyNames() ``` -------------------------------- ### Open New NW.js Window (JavaScript) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This JavaScript code demonstrates how to open a new NW.js window. It takes the URL of the HTML file, a configuration object (optional), and a callback function that executes once the new window is created and ready. ```javascript nw.Window.open('test.html', {}, function (new_win) { // Callback function executed when the new window is created new_win.on('focus', function () { console.log('New window clicked!'); }); }); ``` -------------------------------- ### Inject Custom Windows into Map Scene Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Shows how to hook into the Scene_Map lifecycle to display custom UI elements on the map screen by aliasing the createDisplayObjects method. ```javascript var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects; Scene_Map.prototype.createDisplayObjects = function () { _Scene_Map_createDisplayObjects.call(this); this.addWindow(new Window_Custom()); }; ``` -------------------------------- ### Get Window Size (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves the current width and height of the NW.js window. These properties provide the dimensions of the window in pixels. ```javascript nw.Window.get().width nw.Window.get().height ``` -------------------------------- ### Get RPG Maker MV Map Dimensions Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This section provides JavaScript code to retrieve the height and width of the current map in RPG Maker MV. ```javascript // 获取地图高度 $gameMap.height(); // 获取地图宽度 $gameMap.width(); ``` -------------------------------- ### Basic RPG Maker Native Configuration (JSON) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html A simplified JSON configuration for an RPG Maker native project. It sets the main HTML file, window title, toolbar visibility, dimensions, and icon path. ```json { "name": "", "main": "index.html", "js-flags": "--expose-gc", "window": { "title": "", "toolbar": false, "width": 816, "height": 624, "icon": "icon/icon.png" } } ``` -------------------------------- ### Control RPG Maker MV Scenes Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html These snippets demonstrate how to manage different scenes within RPG Maker MV. This includes setting up battles, opening shop, name input, menu, save, game over, and returning to the title screen. ```javascript // 战斗处理 BattleManager.setup(troopId, true/false, true/false); // 商店处理 SceneManager.push(Scene_Shop); // 名字输入处理 SceneManager.push(Scene_Name); // 打开菜单画面 SceneManager.push(Scene_Menu); // 打开存档画面 SceneManager.push(Scene_Save); // 游戏结束 SceneManager.goto(Scene_Gameover); // 返回标题画面 SceneManager.goto(Scene_Title); ``` -------------------------------- ### Get Highest Party Level in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Returns the level of the highest-level member in the party. This can be used for scaling difficulty or other level-dependent game mechanics. ```javascript $gameParty.highestLevel() ``` -------------------------------- ### System and Environment Utilities Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Functions to toggle FPS display and detect the running environment (NW.js, OS, mobile). ```JavaScript Graphics.showFps(); Graphics.hideFps(); Utils.isNwjs(); Utils.isMobileDevice(); ``` -------------------------------- ### Get Window Position (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves the current X and Y coordinates of the NW.js window relative to the display. This is useful for determining the window's absolute position on the screen. ```javascript nw.Window.get().x nw.Window.get().y ``` -------------------------------- ### Get Event ID by Coordinates (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Finds the ID of the event located at specific map coordinates (x, y). Returns 0 if no event is found at the given position. ```javascript $gameMap.eventIdXy(x,y); ``` -------------------------------- ### Display Dynamic Party Data in Custom Window Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Demonstrates creating a custom window that retrieves and displays live game data, such as the current party member count, within the menu scene. ```javascript function Window_PlayerCount() { this.initialize.apply(this, arguments); } Window_PlayerCount.prototype = Object.create(Window_Base.prototype); Window_PlayerCount.prototype.constructor = Window_PlayerCount; Window_PlayerCount.prototype.initialize = function (x, y) { var width = 240; var height = this.fittingHeight(1); Window_Base.prototype.initialize.call(this, x, y, width, height); this.drawText('Party size: ' + $gameParty.members().length, 0, 0, 200); }; ``` -------------------------------- ### Get Leader Information in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves the leader of the party, typically the first player character. This function is useful for targeting actions or displaying information about the main character. ```javascript $gameParty.leader(); ``` -------------------------------- ### Manage Save Data and Global Info Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Methods for loading game save files and global configuration data. ```JavaScript StorageManager.load(savefileId); DataManager.loadGlobalInfo(); ``` -------------------------------- ### Get Enemy Object (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Accesses the internal array of enemy objects within the troop. Note: Direct manipulation of internal properties like '_enemies' is generally discouraged. ```javascript $gameTroop._enemies[0] ``` -------------------------------- ### Open Default Application with NW.js Shell Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Demonstrates how to use the `nw.Shell` API to open external URLs in the default browser, open files in their default application, and reveal files in the system's file explorer. These functions are part of the NW.js environment. ```javascript // 默认浏览器中打开指定URL nw.Shell.openExternal('https://github.com/nwjs/nw.js'); // 默认编辑器中打开指定文件。 nw.Shell.openItem('test.txt'); // 文件管理器中显示指定文件所在目录。 nw.Shell.showItemInFolder('test.txt'); ``` -------------------------------- ### Get Total Party Member Count in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Returns the total number of members currently in the player's party. This is useful for checks or logic that depends on party size. ```javascript $gameParty.allMembers().length ``` -------------------------------- ### Listen for Window Minimize/Maximize Events (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Sets up event listeners for window minimize and maximize actions. The `on('minimize', ...)` and `on('maximize', ...)` functions execute callback code when these events occur. Listeners can be removed using `removeAllListeners()`. ```javascript // Minimize event listener nw.Window.get().on('minimize', function() { console.log('最小化了!'); }); nw.Window.get().removeAllListeners('minimize'); // Maximize event listener nw.Window.get().on('maximize', function() { console.log('最大化了!'); }); nw.Window.get().removeAllListeners('maximize'); ``` -------------------------------- ### Get Event Movement Speed (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Retrieves the current movement speed of a specific map event. The standard speed is 4, comparable to player movement speed. '11' is the event ID. ```javascript $gameMap._events[11]._moveSpeed ``` -------------------------------- ### Configure RPG Maker MV System Settings Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This section covers various system settings that can be modified in RPG Maker MV. It includes changing background music, victory/defeat ME, vehicle BGM, enabling/disabling save/menu/encounter/formation, and adjusting window colors. ```javascript // 更改战斗BGM $gameSystem.setBattleBgm(this._params[0]); // 更改胜利ME $gameSystem.setVictoryMe(this._params[0]); // 更改战败ME $gameSystem.setDefeatMe(this._params[0]); // 更改载具BGM var vehicle = $gameMap.vehicle(this._params[0]); if (vehicle) { vehicle.setBgm(this._params[1]); } // 启用/禁用存档 $gameSystem.disableSave(); $gameSystem.enableSave(); // 启用/禁用菜单 $gameSystem.disableMenu(); $gameSystem.enableMenu(); // 启用/禁用遇敌 $gameSystem.disableEncounter(); $gameSystem.enableEncounter(); // 启用/禁用整队 $gameSystem.disableFormation(); $gameSystem.enableFormation(); // 更改窗口颜色 (value is an array of 4 elements: rgba) $gameSystem.setWindowTone(value); // Example: Set window RGB to 200, 100, 100 $gameSystem.setWindowTone([200, 100, 100, 0]); ``` -------------------------------- ### RPG Maker MV: Create and Handle Title Command Window Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This JavaScript code extends the Scene_Title prototype to create the title command window and set up handlers for each command. It binds the 'test' command symbol to the custom 'Test' function, which currently alerts 'hello world'. ```javascript Scene_Title.prototype.createCommandWindow = function() { this._commandWindow = new Window_TitleCommand(); this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this)); this._commandWindow.setHandler('continue', this.commandContinue.bind(this)); this._commandWindow.setHandler('options', this.commandOptions.bind(this)); this._commandWindow.setHandler('test', this.Test.bind(this)); this.addWindow(this._commandWindow); }; Scene_Title.prototype.Test = function() { alert("hello world") }; ``` -------------------------------- ### Create Custom Scene in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This JavaScript snippet illustrates how to create a custom scene, `Scene_Test`, by inheriting from `Scene_MenuBase`. It covers scene initialization, creating child windows (like the custom command and help windows), binding command handlers, and managing scene transitions. This allows for entirely new screen functionalities. ```javascript //这个就是点击指令后的场景 function Scene_Test() { this.initialize.apply(this, arguments) } Scene_Test.prototype = Object.create(Scene_MenuBase.prototype);//自行查看窗体所在的场景 Scene_Test.prototype.constructor = Scene_Test; Scene_Test.prototype.initialize = function () { Scene_MenuBase.prototype.initialize.call(this) } Scene_Test.prototype.create = function () { Scene_MenuBase.prototype.create.call(this) this.createTestWindow(); this.createHelpWindow(); this.bindCommands(); } Scene_Test.prototype.start = function () { Scene_MenuBase.prototype.start.call(this) this.windowTest.refresh(); } Scene_Test.prototype.createHelpWindow =function(){ this._helpWindow = new 自定义HELP(); this._helpWindow.setInfo("hello world"); this.addWindow(this._helpWindow); } Scene_Test.prototype.createTestWindow = function () { var x = 0; var y = 0; // console.log(xx,yy) this.windowTest = new Window_Test(x, y) this.addWindow(this.windowTest);//根据需求,可以添加很多个窗口 } Scene_Test.prototype.bindCommands = function () { this.windowTest.setHandler('ok', this.windowOK.bind(this)); this.windowTest.setHandler('cancel', this.windowCancel.bind(this)); } //当点击时触发 Scene_Test.prototype.windowOK = function () { console.log("ok") this.windowTest.activate(); // 监听按键,改变说明区域的文字 this._helpWindow.setInfo("我是自定义的指令哟"); } //当返回时除法 Scene_Test.prototype.windowCancel = function () { console.log("cancel") SceneManager.pop();//返回上一级 } ``` -------------------------------- ### Configure RPGMV HTML and NW.js for Transparency Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Sets the base HTML background to transparent and configures the NW.js window settings to enable transparency and remove window frames. ```html ``` ```json "window": { "frame": false, "transparent": true } ``` -------------------------------- ### Change Actor Profile in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Sets or changes the profile description of a specific actor. The code retrieves the actor by ID (hardcoded to 1 in the example) and applies the new profile text. It includes a check for actor existence. ```javascript var actor = $gameActors.actor(1); ``` ```javascript if (actor) { actor.setProfile(this._params[1]); } ``` -------------------------------- ### Play Video Files Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Command to trigger video playback from the project's movie directory. ```JavaScript Graphics.playVideo('movies/PV.webm'); ``` -------------------------------- ### Access Actor Properties in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Provides access to various properties of a specific actor identified by ID `n`. This includes stats like HP, MP, ATK, DEF, as well as experience, level, and name. Note that IDs start from 1. ```javascript $gameActors.actor(n).agi //角色敏捷 ``` ```javascript $gameActors.actor(n).atk //角色atk ``` ```javascript $gameActors.actor(n).cev //角色会心一击闪躲率 ``` ```javascript $gameActors.actor(n).cnt //角色反击机率 ``` ```javascript $gameActors.actor(n).cri //角色会心攻击机率 ``` ```javascript $gameActors.actor(n).currentExp() //角色当前经验值 ``` ```javascript $gameActors.actor(n).def //角色防御力 ``` ```javascript $gameActors.actor(n).eva //角色闪躲率 ``` ```javascript $gameActors.actor(n).exr //角色经验获得倍率 ``` ```javascript $gameActors.actor(n).fdr //地板类伤害倍率 ``` ```javascript $gameActors.actor(n).grd //角色防御倍率 ``` ```javascript $gameActors.actor(n).hit //角色命中率 ``` ```javascript $gameActors.actor(n).hp //角色hp ``` ```javascript $gameActors.actor(n).hrg //角色hp再生率 ``` ```javascript $gameActors.actor(n).level //角色lv ``` ```javascript $gameActors.actor(n).luk //角色幸运度 ``` ```javascript $gameActors.actor(n).mat//角色魔法攻击力 ``` ```javascript $gameActors.actor(n).mcr//角色MP消耗率 ``` ```javascript $gameActors.actor(n).mdf//角色魔法防御力 ``` ```javascript $gameActors.actor(n).mdr//角色魔法伤害率(减轻) ``` ```javascript $gameActors.actor(n).mev//角色魔法回避率 ``` ```javascript $gameActors.actor(n).mhp//角色最大HP ``` ```javascript $gameActors.actor(n).mmp//角色最大MP ``` ```javascript $gameActors.actor(n).mp//角色MP ``` ```javascript $gameActors.actor(n).mrf//角色魔法反射率 ``` ```javascript $gameActors.actor(n).mrg//角色MP再生率 ``` ```javascript $gameActors.actor(n).nextLevelExp()//角色至下个等级的累计经验值 ``` ```javascript $gameActors.actor(n).nextRequiredExp()//角色至下个等级的经验值 ``` ```javascript $gameActors.actor(n).pdr//角色物理伤害率 ``` ```javascript $gameActors.actor(n).pha//薬の知识 ``` ```javascript $gameActors.actor(n).rec//角色恢复效果率 ``` ```javascript $gameActors.actor(n).tcr//角色TP累积率 ``` ```javascript $gameActors.actor(n).tgr//角色仇恨度(高的容易被怪物瞄准) ``` ```javascript $gameActors.actor(n).tp//角色TP ``` ```javascript $gameActors.actor(n).trg//角色TP恢复率 ``` ```javascript $gameActors.actor(n).name()//角色名字 ``` ```javascript $gameActors.actor(n).actorId()//角色在数据库中的id ``` -------------------------------- ### Get Event Comments/Notes (RPG Maker MV) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Accesses the comment (note) section of a map event. '$dataMap.events[eventID].note' retrieves the raw note content. If notes are structured as key-value pairs (e.g., ''), they can be accessed via the '.meta' property. ```javascript //这个方法可以直接获得注释的内容 $dataMap.events[eventID].note ``` ```javascript //如果注释是以对象形式写的,那么可以用meta属性进行访问 // $dataMap.events[eventID].meta.name ``` ```javascript $dataMap.events[eventID].meta.age ``` -------------------------------- ### Create Custom Command Window in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This snippet demonstrates how to create a custom command window by extending the `Window_Command` class. It includes defining the window, its initialization, and how to add custom commands with associated identifiers. This is a foundational step for creating custom menu interactions. ```javascript (() => { //1.自己的自定义窗体 function Window_Test() { this.initialize.apply(this, arguments); } //2.继承一个窗体类,根据不同需求可以自行改动 Window_Test.prototype = Object.create(Window_Command.prototype); //3.把构造函数指向自己 Window_Test.prototype.constructor = Window_Test; //4.写初始化函数 Window_Test.prototype.initialize = function (x, y) { Window_Command.prototype.initialize.call(this, x, y)//xy代表位置 this.refresh();//刷新窗口 this.activate();//激活 } //窗口类的核心方法,自定义代码就在这里写 Window_Test.prototype.makeCommandList = function () { this.addCommand("自定义的指令", '指令名', true);//指令名是代码内部调用的,可以通过setHandler来使用 //自定义代码,都在这里写。 } })(); ``` -------------------------------- ### Load Real-time Battle System CSS (JavaScript) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Dynamically creates and appends a link element to the document's head to load the 'realtimeBattleSystem.css' stylesheet. This ensures the UI elements have the correct styling. ```javascript RealtimeBattleSystem.loadCSS = function () { var stylesheet = document.createElement("link") stylesheet.rel = "stylesheet" stylesheet.href = "./css/realtimeBattleSystem.css" stylesheet.type = "text/css" document.head.appendChild(stylesheet) } ``` -------------------------------- ### Get Event ID Based on Player Direction in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This JavaScript function, 'getEventID', determines the ID of an event located in front of the player. It calculates the player's adjacent tile based on their current facing direction and then uses '$gameMap.eventIdXy' to retrieve the event ID at that position. This is useful for triggering events or interactions with objects directly in front of the player. ```javascript function getEventID() { var vector = [0, 0]; switch ($gamePlayer.direction()) { case 2: vector = [0, 1] break case 4: vector = [-1, 0] break case 6: vector = [1, 0] break case 8: vector = [0, -1] break default: } var eventPosition = {} eventPosition.x = $gamePlayer.x + vector[0] eventPosition.y = $gamePlayer.y + vector[1] return $gameMap.eventIdXy(eventPosition.x, eventPosition.y) } ``` -------------------------------- ### Initialize Enemy Data (JavaScript) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Initializes an array to store enemy data and then iterates through the game's map events to populate this array. It seems to be setting up the game's enemy entities for the real-time battle system. ```javascript RealtimeBattleSystem.enemyInit = function () { RealtimeBattleSystem._enemys = [] for (let i = 1; i < $dataMap.events.length; i++) { let dataEvent = $dataMap.events[i] } } ``` -------------------------------- ### Custom Keyboard Input Mapping in RPG Maker MV Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Demonstrates how to map physical keyboard keys to custom identifiers using the Input.keyMapper object and how to check the state of these keys using standard input methods. ```JavaScript Input.keyMapper[65] = "A"; Input.isPressed('A'); Input.isTriggered('A'); Input.isRepeated('A'); Input.isLongPressed('A'); ``` -------------------------------- ### Instantiate Game Information Manager (JavaScript) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This snippet demonstrates the instantiation of a custom game information manager object, likely named 'Game_Infor_Manager'. It initializes the object with an ID, a name string, and a date object. ```javascript var $gameInfor = new Game_Infor_Manager(1, "美好的美一天", new Data(2021, 3, 15)); ``` -------------------------------- ### Initialize and Configure Enemy AI Behavior Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Processes map events to assign combat statistics and movement logic based on the event's metadata type. It uses intervals to trigger periodic movement and attack checks against the player. ```JavaScript let gameEvent = $gameMap._events[dataEvent.id]; if (!dataEvent || !dataEvent.meta.type) return; RealtimeBattleSystem._enemys.push(gameEvent); if (dataEvent.meta.type == "车") { gameEvent.hp = 300; gameEvent.attack = 3; gameEvent.setMoveSpeed(4.3); setInterval(function () { gameEvent.moveTowardPlayer(); gameEvent.turnTowardPlayer(); RealtimeBattleSystem.cheackEnemyAttack(gameEvent); }, 700); } if (dataEvent.meta.type == "马") { gameEvent.hp = 350; gameEvent.attack = 5; setInterval(function () { gameEvent.moveTowardPlayer(); setTimeout(function () { switch (RealtimeBattleSystem.eventPositionToPlayer(gameEvent)) { case "右下": gameEvent.moveDiagonally(6, 2); break; case "左下": gameEvent.moveDiagonally(4, 2); break; case "右上": gameEvent.moveDiagonally(6, 8); break; case "左上": gameEvent.moveDiagonally(4, 8); break; } RealtimeBattleSystem.cheackEnemyAttack(gameEvent); }, 500); }, 1000); } if (dataEvent.meta.type == "象") { gameEvent.hp = 250; gameEvent.attack = 10; setInterval(function () { switch (RealtimeBattleSystem.eventPositionToPlayer(gameEvent)) { case "右下": gameEvent.moveDiagonally(6, 2); break; case "左下": gameEvent.moveDiagonally(4, 2); break; case "右上": gameEvent.moveDiagonally(6, 8); break; case "左上": gameEvent.moveDiagonally(4, 8); break; } setTimeout(function () { switch (RealtimeBattleSystem.eventPositionToPlayer(gameEvent)) { case "右下": gameEvent.moveDiagonally(6, 2); break; case "左下": gameEvent.moveDiagonally(4, 2); break; case "右上": gameEvent.moveDiagonally(6, 8); break; case "左上": gameEvent.moveDiagonally(4, 8); break; } RealtimeBattleSystem.cheackEnemyAttack(gameEvent); }, 500); }, 2000); } if (dataEvent.meta.type == "士") { gameEvent.hp = 200; gameEvent.attack = 30; setInterval(function () { if ($gamePlayer.x == 4 && $gamePlayer.y == 2) gameEvent.moveTowardPlayer(); RealtimeBattleSystem.cheackEnemyAttack(gameEvent); }, 1000); } ``` -------------------------------- ### Implement Danmaku System Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html The Danmaku system consists of a configuration class for styling and a main class for managing the lifecycle of bullet comments. It uses setTimeout for scheduling and setInterval for animating the movement of text across the screen. ```javascript class DannmakuConfig { constructor(config) { config = config || {}; this.time = config.time || 1; this.speed = config.speed || 5; this.color = config.color || 'black'; this.fontSize = config.fontSize || '30px'; } } class Danmaku { constructor(texts, ...config) { let tempThis = this; let configs = [new DannmakuConfig()]; for (let i = 0; i < config.length; i++) { configs[i] = new DannmakuConfig(config[i]); } for (let i = 0; i < texts.length; i++) { let useconfig = (i >= configs.length) ? configs[configs.length - 1] : configs[i]; setTimeout(function () { tempThis.send(texts[i], useconfig); }, i * useconfig.time * 1000); } } send(text, config) { let 弹幕 = document.createElement("div"); let node = document.createTextNode(text); 弹幕.appendChild(node); 弹幕.style.position = "fixed"; 弹幕.style.zIndex = "20"; 弹幕.style.whiteSpace = 'nowrap'; let height = window.innerHeight; let width = window.innerWidth; 弹幕.style.top = Math.random() * height * 0.8 + "px"; 弹幕.style.left = width - 300 + "px"; 弹幕.style.color = config.color; 弹幕.style.fontSize = config.fontSize; document.body.appendChild(弹幕); let timeControler = setInterval(() => { 弹幕.style.left = parseInt(弹幕.style.left) - config.speed + "px"; if (parseInt(弹幕.style.left) < -50) { clearInterval(timeControler); 弹幕.parentNode.removeChild(弹幕); } }, 10); } } ``` -------------------------------- ### RPG Maker MV Plugin Template Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This is a template for creating RPG Maker MV plugins. It includes the standard JSDoc header for plugin metadata, parameter definitions, and the structure for handling plugin commands within the Game_Interpreter. This template helps in organizing plugin code and defining its interface. ```javascript /*: * @plugindesc Description of the plugin * * @author Author * * @param First plugin parameter * @desc Description * @default Default value * * @param Second plugin parameter * @desc Description * @default Default value * * * @help * Below are instructions for the script, the format is not mandatory * but at least the usage and plugin commands should be listed. * */ // This is usually your name, but not mandatory, // as long as it's an object. var Yan = Yan || {}; // Below is to register the plugin, the format is fixed // Note that the name must be the same as the filename Yan.Parameters = PluginManager.parameters('Your Plugin Name'); // Below are the plugin parameters, Yan.Parameters.Param1 = String(Yan.Parameters['First plugin parameter'] || 'Default value'); Yan.Parameters.Param2 = String(Yan.Parameters['Second plugin parameter'] || 'Default value'); // The format below is also fixed // Note that if plugin commands are not needed, they can be omitted var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function (command, args) { _Game_Interpreter_pluginCommand.call(this, command, args); // Design your plugin commands, command is the name of your plugin command, of course, there can be more than one, you can use else to create multiple commands if (command === 'PluginCommandName') { // Parameter 0 is your first parameter // For example, the plugin command is command, and the first parameter is one // Then the command is called like this: command one switch (args[0]) { case 'Some': // Code break; case 'SomethingElse': // Code break; } } }; ``` -------------------------------- ### Set Window Size (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Allows resizing the NW.js window to specific dimensions or by a relative amount. `resizeTo(width, height)` sets the exact dimensions, while `resizeBy(width, height)` adjusts the current size by the specified values. ```javascript nw.Window.get().resizeTo(width, height) nw.Window.get().resizeBy(width, height) ``` -------------------------------- ### RPG Maker MV Manifest Configuration (JSON) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html This JSON object defines the configuration for an RPG Maker MV project, specifying the main HTML file, application name, description, version, and window properties. It also includes settings for Node.js integration and WebKit features. ```json { "main": "index.html", "name": "demo", "description": "demo app of node-webkit", "version": "0.1.0", "keywords": ["demo","node-webkit"], "nodejs": true, "node-main": "js/node.js", "single-instance": true, "window": { "title": "demo", "icon": "link.png", "toolbar": false, "resizable": true, "fullscreen": false, "show_in_taskbar": true, "frame": true, "position": "center", "width": 800, "height": 670, "min_width": 400, "min_height": 335, "max_width": 800, "max_height": 670, "show": true, "show_in_taskbar":true, "kiosk": false }, "webkit": { "plugin": true, "java": false, "page-cache": false } } ``` -------------------------------- ### Focus Window (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Brings the NW.js window to the front, ensuring it is the active window. The `focus()` method makes the window the primary focus for user interaction. ```javascript nw.Window.get().focus() ``` -------------------------------- ### Manage Choices and Input Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Methods for creating choice menus, handling user input, and processing item selections. ```JavaScript $gameMessage.setChoices(["我", "是", "选", "项"], 0, 2); $gameMessage.setChoiceBackground(1); $gameMessage.setChoicePositionType(1); $gameMessage.setChoiceCallback(function(n) { console.log("你选择的是第" + (n + 1) + "项!"); }); ``` -------------------------------- ### Maximize/Minimize Window (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Controls the window's state between normal, maximized, and minimized. `enterFullscreen()` and `leaveFullscreen()` handle full-screen mode. `maximize()` and `minimize()` adjust the window size to its maximum or minimum state, respectively. ```javascript nw.Window.get().enterFullscreen(); nw.Window.get().leaveFullscreen(); nw.Window.get().minimize(); nw.Window.get().maximize() ``` -------------------------------- ### Manage Pictures via $gameScreen Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Commands to manipulate on-screen images, including movement, rotation, tinting, and removal. These methods interact directly with the game's screen object to manage picture layers. ```JavaScript $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration); $gameScreen.rotatePicture(pictureId, speed); $gameScreen.tintPicture(pictureId, tone, duration); $gameScreen.erasePicture(pictureId); $gameScreen.clearPictures(); ``` -------------------------------- ### Control Console Window (NW.js SDK) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Manages the developer console window, available only in the SDK mode. `showDevTools()` opens the console, and `closeDevTools()` closes it. `isDevToolsOpen()` checks its current state. ```javascript require('nw.gui').Window.get().showDevTools(); require('nw.gui').Window.get().closeDevTools(); nw.Window.get().isDevToolsOpen() ``` -------------------------------- ### Manage Player State and Followers Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Methods to manipulate the player character's visibility, movement speed, and party follower behavior. ```JavaScript $gamePlayer.setTransparent(true); // Enable transparency $gamePlayer.showFollowers(); // Show party followers $gamePlayer.gatherFollowers(); // Gather followers to player $gamePlayer.setPosition(3, 6); // Set player coordinates ``` -------------------------------- ### Set Window Max/Min Size (NW.js) Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Defines the maximum and minimum dimensions the NW.js window can be resized to. `setMaximumSize(width, height)` sets the upper bounds, and `setMinimumSize(width, height)` sets the lower bounds. ```javascript nw.Window.get().setMaximumSize(width, height) nw.Window.get().setMinimumSize(width, height) ``` -------------------------------- ### Manage Audio Playback Source: https://hat-soft.top/component_notes/RPGMakerMV/html/RPGMV%E9%80%9F%E6%9F%A5.html Functions for playing, fading, saving, and stopping background music (BGM), background sounds (BGS), musical effects (ME), and sound effects (SE). ```JavaScript var bgm = { name: "Name", volume: 100, pitch: 100, pan: 0 }; AudioManager.playBgm(bgm); AudioManager.fadeOutBgm(duration); $gameSystem.saveBgm(); $gameSystem.replayBgm(); AudioManager.playBgs(bgsObject); AudioManager.fadeOutBgs(duration); AudioManager.playMe(meObject); AudioManager.playSe(seObject); AudioManager.stopSe(); ```