| 
 
| 赞 | 52 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 113 |  
| 经验 | 0 |  
| 最后登录 | 2025-5-31 |  
| 在线时间 | 592 小时 |  
 Lv4.逐梦者 
	梦石8 星屑3344 在线时间592 小时注册时间2021-8-13帖子617  
 | 
| 本帖最后由 asukalin 于 2022-10-28 23:42 编辑 
 
   
 我在做的游戏。在主菜单加了一个选项“切换主角”。
 点击“切换主角”再点击人物,会启动公共事件。
 在我的例子里,公共事件就是换到选择的人物当领队。
 你的情况,公共事件大概就是跟选择的人物开始对话。
 
 我是直接修改 rmmz_windows.js 和 rmmz_scenes.js 的。
 
 rmmz_windows.js 关于绘制主菜单选项的那几行,有个叫作 addOriginalCommands() 的选项。
 
 
 复制代码Window_MenuCommand.prototype.makeCommandList = function() {
    this.addMainCommands();
    this.addFormationCommand();
    this.addOriginalCommands();  //这个
    this.addOptionsCommand();
    this.addSaveCommand();
    this.addGameEndCommand();
};
 原本是空的,留给我加东西的。
 
 
 复制代码Window_MenuCommand.prototype.addOriginalCommands = function() {
};
 往里面加东西。
 
 
 复制代码Window_MenuCommand.prototype.addOriginalCommands = function() {
    //这部分是我加的
    const varNoSwitch = 4;
    const enabledPlus = !$gameSwitches.value(varNoSwitch);
    if (this.needsCommand("switchMain")) {
        this.addCommand("切换主角", "switchMain", enabledPlus);
    }
};
 这样,在主菜单上就会多出一个名叫“切换主角”的选项。
 它对应的函数(标签“switchMain”)在 rmmz_scenes.js 那边。
 
 
 复制代码Scene_Menu.prototype.createCommandWindow = function() {
    const rect = this.commandWindowRect();
    const commandWindow = new Window_MenuCommand(rect);
    commandWindow.setHandler("switchMain", this.commandSwitchMain.bind(this));        //这行是我插进去的
    commandWindow.setHandler("item", this.commandItem.bind(this));
    commandWindow.setHandler("skill", this.commandPersonal.bind(this));
    commandWindow.setHandler("equip", this.commandPersonal.bind(this));
    commandWindow.setHandler("status", this.commandPersonal.bind(this));
    commandWindow.setHandler("formation", this.commandFormation.bind(this));
    commandWindow.setHandler("options", this.commandOptions.bind(this));
    commandWindow.setHandler("save", this.commandSave.bind(this));
    commandWindow.setHandler("gameEnd", this.commandGameEnd.bind(this));
    commandWindow.setHandler("cancel", this.popScene.bind(this));
    this.addWindow(commandWindow);
    this._commandWindow = commandWindow;
};
//这是"switchMain"的具体内容
Scene_Menu.prototype.commandSwitchMain = function() {
    this._statusWindow.setFormationMode(true);
    this._statusWindow.selectLast();
    this._statusWindow.activate();
    this._statusWindow.setHandler("ok", this.onSwitchMainOk.bind(this));            //如果按了“切换主角”选项会怎么样
    this._statusWindow.setHandler("cancel", this.onSwitchMainCancel.bind(this));    //如果按了取消键会怎么样
};
//这部分是按下“切换主角”选项之后会运行的内容
Scene_Menu.prototype.onSwitchMainOk = function() {
    //这里面,需要自己具体写了
    //.....(省略)
    //总而言之,到了最后都要运行公共事件
    $gameTemp.reserveCommonEvent(id);  //运行第id号公共事件
};
 
 我用的是MZ,和MV可能有点不一样。
 我不懂代码,这些修改都是拼拼凑凑给弄出来的。
 
 | 
 |