MV [SOLVED] Allow player to select magic skill even if they don't have enough magic

The problem has been solved thanks to the work of caethyril and Fortunastreet!

They helped build this plugin, which I have attached to this post to download so that future users whom wish to solve this problem may be able to get it resolved quickly.

The plugin lacks QoL options, such as plugin options from within the editor's plugin manager, but all of us involved - caethyril, Fortunastreet, and myself - have commented the plugin from top to bottom to make it as accessible as possible for the layman.

How to set it up:
Since the plugin lacks plugin options, you'll need an IDE to edit the code. I recommend Notepad++.
Download the plugin linked in this thread. By default the plugin is set to display the message "[Character name] does not have enough MP!"
To change this, open the plugin in your IDE. On Windows, you may need to right-click "Open with..." and select Notepad++ or your IDE of choice.
You'll find the comment on line 25 "//set displayed message here."
Change the text on line 25 found between the quotation marks " does not have enough MP!" to your desired text.
Save it.
Done!

(the original post has been stuffed into the spoiler tag below)
Spoiler: Original Post
As the title says.

By default, RPG Maker won't let the player select any skills they don't have enough magic to cast. This becomes a problem when, say for example, in a single turn you first cast a skill that restores MP in order for the following action (again, still the same turn) to be a skill that costs MP.

As far as I am aware, RPG Maker will automatically cancel any skill and skip the action if (say for example) an enemy drained the player's MP before they had a chance to cast the skill, so it would be nice if it would basically behave the same way. If the player selects the skill and doesn't have enough MP, it just cancels their turn, but if they do have enough MP, they cast it.

I feel like this should be a plugin that already exists :LZSskeptic:, but I'll be darned if I can't figure out how to google search this problem. I tried and just mostly brought discussions around magic systems, but no plugins.
So if i Click the wrong Skill i end up not attacking at all in that turn, because i did not
pay attention to the fact that i have not enough MP? Are you sure you want that?
because i did not
pay attention to the fact that i have not enough MP? Are you sure you want that?
Yes, and yes.
I haven't tested, but you could try saving this as a .js file and importing as a plugin:
JavaScript:
/*:
 * @plugindesc In battle, allow selection of any skill regardless of usability.
 * @help Free to use and/or modify for any project, no credit required.
 */
Window_BattleSkill.prototype.isEnabled = function(item) { return true; };
I haven't tested, but you could try saving this as a .js file and importing as a plugin:
Nice, it worked :LZSproud: thank you so much!
How tough would it be to add some text to the battle log, like a basic message that just says "Not enough MP"?
Nice, it worked :LZSproud: thank you so much!
How tough would it be to add some text to the battle log, like a basic message that just says "Not enough MP"?

Depending of your Battle System, you have somewhere in your code something like this:
JavaScript:
if (action.isValid()) {
    this.startAction();
}
subject.removeCurrentAction();

What you need to do, is to add an 'else' close to the if, with this code in it:
JavaScript:
this._logWindow.displayCanNotUseMessage(battler);

The called function would be something like that:
JavaScript:
Window_BattleLog.prototype.displayCanNotUseMessage = function(subject) {
    // Show your message here
    this.push('addText', subject.name() + " YOUR FANCY MESSAGE");
    // Put here as many 'wait' command as you want, each wait is 16 frames.
    this.push('wait');
    this.push('wait');
    this.push('wait');
    this.push('wait');
    // Clear the battle log
    this.push('clear');
};
Looks good, but for compatibility with other plugins it may be better to do that by patching instead of an edit/override, e.g. by adding this to the plugin code I suggested earlier:
JavaScript:
;void (function(alias) {
  BattleManager.processTurn = function() {
    // check if the subject's next action exists and is unusable
    var action = this._subject.currentAction();
    if (action && !action.isValid())
      this.displayCanNotUseMessage(this._subject);
    // call original method
    alias.apply(this, arguments);
  };
})(BattleManager.processTurn);

BattleManager.displayCanNotUseMessage = function(subject) {
  // etc
};
Also, note that there's no guarantee that the action is invalid due to lack of mana. You'd need extra checks/workarounds for that.
Thanks to both of your, @Fortunastreet & @caethyril
I'm not sure where to put the actual message information in caethyril's code.
Under the //etc comment, should I just use (quote) "message message message"? Or do I need to use the code provided by Fortunastreet underneath the //etc comment?
Oops, I defined displayCanNotUseMessage on BattleManager, rather than on Window_BattleLog like Fortunastreet did. 😅

A closer match would be this:
JavaScript:
;void (function(alias) {
  BattleManager.processTurn = function() {
    // check if the subject's next action exists and is unusable
    var action = this._subject.currentAction();
    if (action && !action.isValid())
      this._logWindow.displayCanNotUseMessage(this._subject);
    // call original method
    alias.apply(this, arguments);
  };
})(BattleManager.processTurn);

// This function is from Fortunastreet's post.
Window_BattleLog.prototype.displayCanNotUseMessage = function(subject) {
    // Show your message here
    this.push('addText', subject.name() + " YOUR FANCY MESSAGE");
    // Put here as many 'wait' command as you want, each wait is 16 frames.
    this.push('wait');
    this.push('wait');
    this.push('wait');
    this.push('wait');
    // Clear the battle log
    this.push('clear');
};
Sorry for the confusion! 😴
Wow, thank you so much! Yes it works perfectly!
Here, I gave the plugin a marketable name in case you want to distribute it. Fortunastreet is listed in the credits as well.
I'll edit the main topic for future users whom might be searching for this kind of thing and then mark the thread for closure.

edit:
I had poor grammar on the displayed message in the plugin. I changed my grammar and have uploaded a new version of the plugin.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-allow-player-to-select-magic-skill-even-if-they-dont-have-enough-magic.150113/