じ☆ve冰风 发表于 2026-7-27 09:51:05

Autostart one Parallel Common Event

Hello Guys,

i needed to build a plugin to start one common event parallel, when a map is loaded.
When you need something similar you can download the plugin or see how it works in the spoiler.

Spoiler: Js - Code                Code:       
//=============================================================================
// MURA_RunParalell.js v1
//=============================================================================
"use strict";
var Imported = Imported || {};
Imported.MURA_RunParalell = true;

var Murakui = Murakui || {};
Murakui.RunParalell = Murakui.RunParalell || {};

//=============================================================================
// Plugin Parameters
//=============================================================================
/*:
* @plugindesc process one common event anytime
* @author murakui
*
* @param Event ID
* @desc 1-9999
* @default 1
*
* @help This plugin runs one of the common events globally at any map.
*
* Please select one common event that contains the trigger: 'Paralell'
* and select a switch.
*
* When the map is loaded the gameengine updates the switch to true,
* that will trigger the common event permanently as long the game is running.
*
*/
(function ($rp) {

    $rp.parameters = PluginManager.parameters('MURA_RunParalell');
    $rp.eventId = $rp.parameters['Event ID'];

    Game_CommonEvent.prototype.isActive = function () {
      $rp.changeSwitchForEvent(this.event());
      return $rp.isTriggerParalell(this.event().trigger) && $rp.isSwitchOn(this.event().switchId);
    };

    $rp.changeSwitchForEvent = function (event) {
      if (!$rp.isSwitchOn(event.switchId) && $rp.isEventIdEqual(event.id)) {
            $rp.setSwitch(event.switchId, true);
      };
    };

    $rp.isSwitchOn = function (switchId) {
      return $gameSwitches.value(switchId);
    };

    $rp.isTriggerParalell = function (trigger) {
      return trigger == 2;
    };

    $rp.isEventIdEqual = function (eventId) {
      return $rp.eventId == eventId;
    }

    $rp.setSwitch = function (switchId, bool) {
      $gameSwitches.setValue(switchId, bool);
    }

})(Murakui.RunParalell);


regards,
Mura

Terms of Use: Use it as you please.


本贴来自国际rpgmaker官方论坛作者:Murakui处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/autostart-one-parallel-common-event.108708/
页: [1]
查看完整版本: Autostart one Parallel Common Event