Yanfly's SelfSwVar plus Moghunter's Chrono compatibility

Xenphir

Nature's Friend
Veteran
Joined
Nov 20, 2017
Messages
198
Reaction score
133
First Language
English
Primarily Uses
RMMV
So I encountered an issue. My game requires ABS battle system and Chrono is the only one I have found that works for me well. However there is an issue using it with Yanfly's SelfSwVar plugin, which I also have to use for complicated event processes.

The plugins work fine together most of the time, as far as I can tell. The only time an issue comes up is when an enemy in ABS battle dies. I turn off the SelfSwVar plugin and the error doesn't happen, but when I turn it back on, it does. So I know for sure it is this plugin. I have taken damage from enemies and swung at them. Sometimes this error comes up from swinging at the enemy before its HP could reach zero, but it always happens for sure when the enemy dies. The error is screenshot below. It states, "key[2].match is not a function". I'm not sure if it was a key on the keyboard but I can't see anywhere to adjust any sort of key that might have an issue? The attack button is the enter, OK, or Z key. Yanfly's Selfswvar plugin doesn't seem to use keys at all. Unless Key means something else in this case?

65166cf8b4ce5afd9c7770302f49428c.png
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,159
Reaction score
10,746
First Language
Czech
Primarily Uses
RMMV
Screenshot of the console (f8) would be much better than this.
 

Xenphir

Nature's Friend
Veteran
Joined
Nov 20, 2017
Messages
198
Reaction score
133
First Language
English
Primarily Uses
RMMV
F8 didn't work so I just pressed all the F-buttons and this is what came up. Is this the console?

fcf75edfa20d419f7604b93389c66000.png
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,159
Reaction score
10,746
First Language
Czech
Primarily Uses
RMMV
Yup, that is console. Can't take a look now, since I'm at work, but it shows the error location.
 

Xenphir

Nature's Friend
Veteran
Joined
Nov 20, 2017
Messages
198
Reaction score
133
First Language
English
Primarily Uses
RMMV
Yup, that is console. Can't take a look now, since I'm at work, but it shows the error location.
Yeah im not sure how to fix it since I dont understand code but I at least know now that (well im guessing mostly by the words) moghunter uses hidden self variables in their events and its clashing with yanflys directly.
 

Xenphir

Nature's Friend
Veteran
Joined
Nov 20, 2017
Messages
198
Reaction score
133
First Language
English
Primarily Uses
RMMV
Been awhile so gonna bump this.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,159
Reaction score
10,746
First Language
Czech
Primarily Uses
RMMV
Sorry, completely forgot about this. I identified the problem, but fixing it would require to rework the entire plugin. The reason is, MOG tries to use the self switches standard MV engine way. Yanfly has introduced her own formatting to the self switches.
 

Xenphir

Nature's Friend
Veteran
Joined
Nov 20, 2017
Messages
198
Reaction score
133
First Language
English
Primarily Uses
RMMV
Sorry, completely forgot about this. I identified the problem, but fixing it would require to rework the entire plugin. The reason is, MOG tries to use the self switches standard MV engine way. Yanfly has introduced her own formatting to the self switches.
ah okay thanks. Is there a way to turn plugins off and on mid-game via a switch? If so I could simply not use any events that require her self-switch/variables in battle-areas for now, until I can afford my own plugin.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,159
Reaction score
10,746
First Language
Czech
Primarily Uses
RMMV
There is no native way to unload a plugin via a switch. The reason is, upon adding as a script element, the parser will parse through all functions in the plugin and define them. There's no way to unparse a function or revert it to previous change except via a redefinition. However, in order to redefine a function you need to operate on a top level.
So that means there is pretty much only one workaround.
Having a .js file inside the game js/plugins folder. It would contain this code:
Code:
Game_SelfSwitches.prototype.value = Yanfly.SSV.Game_SelfSwitches_value;
Game_SelfSwitches.prototype.setValue = Yanfly.SSV.Game_SelfSwitches_setValue;
Game_SelfSwitches.prototype.onChange = Yanfly.SSV.Game_SelfSwitches_setValue;
in other words it contains code to revert Yanfly's changes.

Then you'd have another file, which contains these functions:
Code:
Yanfly.SSV.Game_SelfSwitches_value = Game_SelfSwitches.prototype.value;
Game_SelfSwitches.prototype.value = function(key) {
  if (key[2].match(/SELF[ ]VAR/i)) {
    this._data[key] = this._data[key] || 0;
    return this._data[key];
  }
  return Yanfly.SSV.Game_SelfSwitches_value.call(this, key);
};

Yanfly.SSV.Game_SelfSwitches_setValue = Game_SelfSwitches.prototype.setValue;
Game_SelfSwitches.prototype.setValue = function(key, value) {
  if (key[2].match(/SELF[ ]VAR/i)) {
    this._data[key] = value;
    this.onChange();
  } else {
    Yanfly.SSV.Game_SelfSwitches_setValue.call(this, key, value)
  }
};

Yanfly.SSV.Game_SelfSwitches_onChange = Game_SelfSwitches.prototype.onChange;
Game_SelfSwitches.prototype.onChange = function() {
  Yanfly.SSV.Game_SelfSwitches_onChange.call(this);
  if ($gameTemp.getSelfSwVarEventOneTimeClear()) {
    $gameTemp.setSelfSwVarEventOneTimeClear(false);
    $gameTemp.clearSelfSwVarEvent();
  }
};
In other words it implements Yanfly's changes back.

Then you'd have a plugin file that loads whatever plugin is necessary on demand. I'm including the base of this plugin in this reply, however since I have absolutely no idea when you use self switches, I don't know where should I even plant the functions necessary to call. So I kind of hope you figure that out :D
Btw. using these functions it would be possible to make it possible to load/unload the plugin via switch.
 

Attachments

  • YanflySSVManager.js
    1,017 bytes · Views: 8

KtheNerd

Villager
Member
Joined
Dec 2, 2016
Messages
13
Reaction score
3
First Language
English
Primarily Uses
RMMV
Since MOG's Chrono Engine uses self switches for determining if the player is close enough (via Event Sensor Plugin) and when the event is dead (via Chrono Engine Plugin), how would I implement the code you gave?
 
Last edited:

Latest Threads

Latest Profile Posts

It's definitely discouraging when streamers give a try-to-say-it-nicely (i.e. bad) review of your game demo. It's like jumping into a cold pool. Bad initally, but it gets better with time. And you are now more alert and see better.
Some screenshots of the pub and lodging with the beginnings of clutter taking shape
TTp8uCw.png

jtC202e.png

bSXgyVl.png

eRx9PUF.png
Backgrounds are not my strong suit... :kaodes:
DazI8jt.jpg

Just realized I forgot doing the clouds... woops
Went to get some stuff for February 10, the birthday of my favorite ink monster...
I have a little one-person party for Bendy every year, complete with the life-size plushie I made. And yes, I bake a birthday cake!

Forum statistics

Threads
118,497
Messages
1,116,407
Members
155,489
Latest member
Desarr0
Top