Advertisement
Ellye

Ellye Class Changing Equips

Oct 31st, 2015
1,719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Place file inside /js/plugins
  2. // Remember to save after adding plugins or changing parameters.
  3. //=============================================================================
  4. // Ellye's Class Changing Equip
  5. //=============================================================================
  6. /*:
  7.  * Version: 2015-10-31-2300
  8.  *
  9.  * CHANGE LOG:
  10.  * 2015-10-31-2300- Released.
  11.  *
  12.  *
  13.  * @plugindesc Ver.2015-10-31-2300. Equips that can change class. See help.
  14.  * <Ellye CCE>
  15.  * @author https://ellyeblog.wordpress.com/ || http://steamcommunity.com/id/Ellye
  16.  *
  17.  * @param Keep EXP
  18.  * @desc Whether to keep EXP/level between classes. 0: off, 1: on. Default: 1
  19.  * @default 1
  20.  *
  21.  *
  22.  * @help This plugin allows you set up a custom Note in your equips to make it change anyone who equips them to another class.
  23.  * In the [Note] field of an Equipment, include:
  24.  * <change_class:CLASS_ID_HERE>
  25.  *
  26.  * For example:
  27.  * <change_class:3>
  28.  * Would change anyone who equips the item to class #3.
  29.  * The character goes back to his base class when he unequips that piece of armor.
  30.  *
  31.  * Highly recommendable that you only ever use this in one type of item in your project (otherwise you'd get into sutiation with multiple class changing items equipped at the same time, in which case the order of equipping would matter)
  32.  *
  33.  */
  34. (function() {
  35.  
  36.     var parameters = $plugins.filter(function(p) {
  37.         return p.description.contains('<Ellye CCE>');
  38.     })[0].parameters; //Thanks to Iavra
  39.     var keep_exp = Boolean(parameters['Keep EXP'] || true);
  40.  
  41.     //Let's add a new variable for Game_Actor that will hold its base, starting class:
  42.     _Game_Actor_prototype_setup_alias = Game_Actor.prototype.setup;
  43.     Game_Actor.prototype.setup = function(actorId) {
  44.         _Game_Actor_prototype_setup_alias.call(this, actorId);
  45.         this._startingClass = this._classId;
  46.     };
  47.  
  48.     //Let's call for class changing logic in both ChangeEquip and ForceChangeEquip
  49.     Game_Actor.prototype.changeEquip = function(slotId, item) {
  50.         if (this.tradeItemWithParty(item, this.equips()[slotId]) && (!item || this.equipSlots()[slotId] === item.etypeId))
  51.         {
  52.             this.checkForClassChangeFromEquips(this.equips()[slotId], item);
  53.             this._equips[slotId].setObject(item);
  54.             this.refresh();
  55.         }
  56.     };
  57.  
  58.     _alias_force_change_equip = Game_Actor.prototype.forceChangeEquip;
  59.     Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
  60.         this.checkForClassChangeFromEquips(this.equips()[slotId], item);
  61.         _alias_force_change_equip.call(this, slotId, item);
  62.     };
  63.  
  64.     Game_Actor.prototype.discardEquip = function(item) {
  65.         var slotId = this.equips().indexOf(item);
  66.         if (slotId >= 0) {
  67.             this.checkForClassChangeFromEquips(item, null);
  68.             this._equips[slotId].setObject(null);
  69.         }
  70.     };
  71.  
  72.     //Our main method:
  73.     Game_Actor.prototype.checkForClassChangeFromEquips = function(old_equip, new_equip)
  74.     {
  75.         if (old_equip !== null && typeof old_equip === 'object' && typeof old_equip.meta.change_class !== 'undefined')
  76.         {
  77.             this.changeClass(this._startingClass, keep_exp);
  78.         }
  79.         if (new_equip !== null && typeof new_equip === 'object' && typeof new_equip.meta.change_class !== 'undefined')
  80.         {
  81.             this.changeClass(new_equip.meta.change_class, keep_exp);
  82.         }
  83.         this.releaseUnequippableItems(false);
  84.     };
  85.  
  86. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement