Execute common event when any event is triggered.

coolperez8

Veteran
Veteran
Joined
Mar 23, 2016
Messages
159
Reaction score
12
First Language
English
Primarily Uses
So, what I want to do is execute a common event from the game, so whenever the player interacts with an event, it will run the common event and then run the event.


The reason for this is because I have a lot of events in my game and don't want to have to add the run common event to the beginning of every event in the game.


Is there any simple way to do this, like a plugin?
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
There is literally a reserve common event command in the event commands pages.

 

coolperez8

Veteran
Veteran
Joined
Mar 23, 2016
Messages
159
Reaction score
12
First Language
English
Primarily Uses
There is literally a reserve common event command in the event commands pages.

I know, but I don't want to have to add that manually for every event in the game.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
If you want it to run before any event in the game, you'll either need to put that in every event, or use a plugin. Of course I don't know about every plugin made so far, but I don't know of any that does what you're looking for.
 

coolperez8

Veteran
Veteran
Joined
Mar 23, 2016
Messages
159
Reaction score
12
First Language
English
Primarily Uses
If you want it to run before any event in the game, you'll either need to put that in every event, or use a plugin. Of course I don't know about every plugin made so far, but I don't know of any that does what you're looking for.
Okay.


Guess I might have to make my own, but I'm new to programming for RPG Maker MV.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Theoretically it shouldn't be that hard, since you want this to be done to every event, the easiest solution would probably be to alias the Game_Event's list function to get the list of event commands, and just pop the common event call in the beginning.


It looks roughly like this:




Just be sure to actually alias it, not just put things in the default scripts. That's bad practice, it'd be better to make it a plugin, with a parameter for which common event to call.


EDIT: Also I forgot to change the return statement to "return list;"
 
Last edited by a moderator:

coolperez8

Veteran
Veteran
Joined
Mar 23, 2016
Messages
159
Reaction score
12
First Language
English
Primarily Uses
Theoretically it shouldn't be that hard, since you want this to be done to every event, the easiest solution would probably be to alias the Game_Event's list function to get the list of event commands, and just pop the common event call in the beginning.


It looks roughly like this:




Just be sure to actually alias it, not just put things in the default scripts. That's bad practice, it'd be better to make it a plugin, with a parameter for which common event to call.
ok
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
You can use this plugin:

Code:
/*:
 * @plugindesc Call a Common Event before any event <CommonEventBeforeAnyEvent>
 * @author Hudell
 *
 * @param commonEventId
 * @desc The Id of the common event
 * @default 0
 *
 * @help
 * ============================================================================
 * Hudell's Plugins
 * ============================================================================
 * 
 * Check out my website:
 * http://hudell.com
 * 
 *=============================================================================*/
var Imported = Imported || {};
var CommonEventBeforeAnyEvent = {};

(function($) {
  "use strict";

  var parameters = $plugins.filter(function(plugin) { return plugin.description.contains('<CommonEventBeforeAnyEvent>'); });
  if (parameters.length === 0) {
    throw new Error("Couldn't find parameters of CommonEventBeforeAnyEvent.");
  }
  $.Parameters = parameters[0].parameters;
  $.Param = {};

  $.Param.commonEventId = Number($.Parameters.commonEventId || 0);

  var oldGameInterpreter_setup = Game_Interpreter.prototype.setup;

  Game_Interpreter.prototype.setup = function(list, eventId) {
    oldGameInterpreter_setup.call(this, list, eventId);

    if (this._depth === 0) {
      var commonEvent = $dataCommonEvents[$.Param.commonEventId];
      if (!!commonEvent) {
        this.setupChild(commonEvent.list, eventId);
      }
    }
  };
})(CommonEventBeforeAnyEvent);
 

coolperez8

Veteran
Veteran
Joined
Mar 23, 2016
Messages
159
Reaction score
12
First Language
English
Primarily Uses
You can use this plugin:



/*:
* @plugindesc Call a Common Event before any event <CommonEventBeforeAnyEvent>
* @author Hudell
*
* @param commonEventId
* @desc The Id of the common event
* @default 0
*
* @help
* ============================================================================
* Hudell's Plugins
* ============================================================================
*
* Check out my website:
* http://hudell.com
*
*=============================================================================*/
var Imported = Imported || {};
var CommonEventBeforeAnyEvent = {};

(function($) {
"use strict";

var parameters = $plugins.filter(function(plugin) { return plugin.description.contains('<CommonEventBeforeAnyEvent>'); });
if (parameters.length === 0) {
throw new Error("Couldn't find parameters of CommonEventBeforeAnyEvent.");
}
$.Parameters = parameters[0].parameters;
$.Param = {};

$.Param.commonEventId = Number($.Parameters.commonEventId || 0);

var oldGameInterpreter_setup = Game_Interpreter.prototype.setup;

Game_Interpreter.prototype.setup = function(list, eventId) {
oldGameInterpreter_setup.call(this, list, eventId);

if (this._depth === 0) {
var commonEvent = $dataCommonEvents[$.Param.commonEventId];
if (!!commonEvent) {
this.setupChild(commonEvent.list, eventId);
}
}
};
})(CommonEventBeforeAnyEvent);
Thanks
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top