SSTrihan

Trilobytes - No MP? No Problem! plugin

Feb 27th, 2022 (edited)
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Trilobytes - No MP? No Problem!
  3. // TLB_NoMPNoProblem.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.TLB_NoMPNoProblem = true;
  8.  
  9. var TLB = TLB || {};
  10. TLB.NoMPNoProblem ??= {};
  11. TLB.NoMPNoProblem.version = 1.00;
  12.  
  13. /*:
  14.  * @target MZ
  15.  * @plugindesc This plugin allows battlers to attack instead of using a skill
  16.  * or item if they couldn't pay the cost.
  17.  * @author John Clifford/Trihan
  18.  *
  19.  * @help
  20.  * ============================================================================
  21.  * Introduction
  22.  * ============================================================================
  23.  *
  24.  * This plugin causes a battler who can't pay the cost for their chosen skill
  25.  * or item to attempt a normal attack instead.
  26.  *
  27.  * ============================================================================
  28.  * Plugin Commands
  29.  * ============================================================================
  30.  *
  31.  * None
  32.  *
  33.  * ============================================================================
  34.  * Plugin Parameters
  35.  * ============================================================================
  36.  *
  37.  * None
  38.  *
  39.  * ============================================================================
  40.  * Compatibility
  41.  * ============================================================================
  42.  *
  43.  *  May clash with other plugins that affect BattleManager's processTurn.
  44.  *
  45.  * ============================================================================
  46.  * Changelog
  47.  * ============================================================================
  48.  *
  49.  * Version 1.00:
  50.  * - Finished plugin!
  51.  *
  52.  */
  53.    
  54. Game_BattlerBase.prototype.meetsSkillConditionsBesidesCost = function(skill) {
  55.     return (
  56.         this.meetsUsableItemConditions(skill) &&
  57.         this.isSkillWtypeOk(skill) &&
  58.         !this.isSkillSealed(skill.id) &&
  59.         !this.isSkillTypeSealed(skill.stypeId)
  60.     );
  61. };
  62.  
  63. TLB.NoMPNoProblem.BattleManager_processTurn = BattleManager.processTurn;
  64. BattleManager.processTurn = function() {
  65.     const subject = this._subject;
  66.     const action = subject.currentAction();
  67.     if (action) {
  68.         action.prepare();
  69.         if (!action.isValid() && subject.meetsSkillConditionsBesidesCost(action.item())) {
  70.             action.setAttack();
  71.         }
  72.     }
  73.     TLB.NoMPNoProblem.BattleManager_processTurn.call(this);
  74. };
Add Comment
Please, Sign In to add comment