Advertisement
MV_Musashi

Class Items

Nov 10th, 2015
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //====================================================================================
  2. //
  3. // Class Items
  4. //
  5. //====================================================================================
  6. /*:
  7. * @plugindesc Specify items to be used only by certain classes.
  8. * @author Musashii
  9. *
  10. * @help
  11. * Use the notetag <classItem: id> in the Items Note to determine which class can
  12. * use it. If no notetag is set the item will be available for all.
  13. *
  14. * Use <onlyAffect: id> inside items Note to make it affect only the class id.
  15. */
  16. //====================================================================================
  17.  
  18.  
  19. var usersClass = 0;
  20. var waitUseItem = 0;
  21.  
  22. (function() {
  23.  
  24. //===================================
  25. // Update Counter
  26. //===================================
  27. var _Window_BattleLog_startTurn = Window_BattleLog.prototype.startTurn;
  28.            
  29. Window_BattleLog.prototype.startTurn = function() {
  30. waitUseItem = 100
  31. _Window_BattleLog_startTurn.call
  32. };
  33.  
  34. //===================================
  35. //Replace meetsItemConditions
  36. //===================================
  37. Game_BattlerBase.prototype.meetsItemConditions = function(item) {
  38.  //usersClass = this._classId
  39.   if(waitUseItem === 100){usersClass = this._classId}
  40.  
  41.   //can't use item in menu if any actor in party have the class
  42.   var checkClassInParty = 0;
  43. $gameParty.allMembers().forEach(function(entry){
  44.   if(entry._classId == item.meta.classItem)
  45.     checkClassInParty = 1;
  46. });
  47. if (item.meta.classItem === undefined){checkClassInParty = 1}
  48.     return this.meetsUsableItemConditions(item) && $gameParty.hasItem(item) && checkClassInParty === 1;
  49. };
  50.  
  51. //===================================
  52. // Get active actor's class ID + reset Counter
  53. //===================================
  54. var _Scene_Battle_startActorCommandSelection = Scene_Battle.prototype.startActorCommandSelection;
  55.  
  56. Scene_Battle.prototype.startActorCommandSelection = function() {
  57.  
  58.    usersClass = BattleManager.actor()._classId
  59.    waitUseItem = 0
  60.     this._statusWindow.select(BattleManager.actor().index());
  61.     this._partyCommandWindow.close();
  62.     this._actorCommandWindow.setup(BattleManager.actor());
  63.        _Scene_Battle_startActorCommandSelection.call
  64. };
  65.  
  66. //===================================
  67. //Replace isOccasionOk
  68. //===================================
  69. Game_BattlerBase.prototype.isOccasionOk = function(item) {
  70.     if ($gameParty.inBattle()) {
  71.     if (item.meta.classItem === undefined){
  72.         return item.occasion === 0 || item.occasion === 1;}
  73.         else{
  74.         if (usersClass === Number(item.meta.classItem)){
  75.         return item.occasion === 0 || item.occasion === 1;
  76.         }else{
  77.         return false;
  78.         }
  79.         }
  80.     } else {
  81.         return item.occasion === 0 || item.occasion === 2;
  82.     }
  83. };
  84. //===================================================================================
  85. Game_Action.prototype.testApply = function(target) {
  86.  
  87. if(this._item._dataClass === "item" && $dataItems[this._item._itemId].meta.onlyAffect != undefined){
  88.  
  89. return (Number(this.isTeste()) === target._classId);
  90. }
  91. else{
  92.  
  93.  
  94.  
  95.     return (this.isForDeadFriend() === target.isDead() &&
  96.             ($gameParty.inBattle() || this.isForOpponent() ||
  97.             (this.isHpRecover() && target.hp < target.mhp) ||
  98.             (this.isMpRecover() && target.mp < target.mmp) ||
  99.             (this.hasItemAnyValidEffects(target))));}
  100. };
  101.  
  102.  
  103. Game_Action.prototype.isTeste = function() {
  104.     return $dataItems[this._item._itemId].meta.onlyAffect;
  105. };
  106.  
  107.   })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement