Rafael_Sol_Maker

RSM's Custom Commands for built-in Variables MV (BETA)

Jun 10th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ** CustomVariableCommandsBETA.js
  3. //-----------------------------------------------------------------------------
  4. //    Rafael_Sol_Maker's Custom Commands for built-in Variables MV (BETA)
  5. //            This work is licensed under a Creative Commons
  6. //                 Attribution 4.0 International License.
  7. //=============================================================================
  8. /*:
  9.  * @plugindesc (BETA) Custom Commands for built-in Variables MV. (BETA)
  10.  * WARNING: This plugin is experimental and very sensible to wrong values!
  11.  * @author Rafael_Sol_MAKER (www.condadobraveheart.com)
  12.  *
  13.  * @help
  14.  * (This plugins has no parameters to configure)
  15.  *
  16.  * Plugin Commands:
  17.  *
  18.  *   ConditionalBranchActor <actor_id> <condition> <value> <switch>
  19.  *      Where: <actor_id> Represents the variable to store the actor's id
  20.  *             <condition> OnGroup?, Name, Class, Skill, Weapon, Armor or State
  21.  *             <value> true/false, "Some Text" or item id (use wisely!)
  22.  *             <switch> Id of the switch activated, if the condition is met
  23.  *
  24.  *   ChangeAllItems <item_type> <item_id> <ammount> <includeEquips?>
  25.  *      Where: <item_type> Items, Weapons or Armors
  26.  *             <item_id> Id of the item, weapon or armor you want to manipulate
  27.  *             <ammount> Put the quantity here (including negative)
  28.  *             <includeEquips?> If equiped items are considered (for removal)
  29.  *
  30.  *   ChangePartyMember <actor_id> <operation> <reset?>
  31.  *      Where: <actor_id> Represents the variable to store the actor's id
  32.  *             <operation> Add or Remove
  33.  *             <reset> If you want to reset the hero to initial conditions
  34.  *
  35.  *   ChangeEquipment <actor_id> <type> <equip_id>
  36.  *      Where: <actor_id> Represents the variable to store the actor's id
  37.  *             <id_equip_type> Put the id of the type of equipment
  38.  *             <equip_id> Id of weapon or armor to equip in the given hero
  39.  *
  40.  *   ChangeName <actor_id> <data>
  41.  *      Where: <actor_id> Represents the variable to store the actor's id
  42.  *             <data> The text that will be the new name
  43.  *
  44.  *   ChangeClass <actor_id> <class_id> <keep_exp?>
  45.  *      Where: <actor_id> Represents the variable to store the actor's id
  46.  *             <class_id> Id of the class that you want
  47.  *             <keep_exp?> If you want to keep the exp. the hero already have
  48.  *
  49.  *   ChangeNickname <actor_id> <data>
  50.  *      Where: <actor_id> Represents the variable to store the actor's id
  51.  *             <data> The new nickname you desire for your character
  52.  *
  53.  *   ChangeProfile <actor_id> <data>
  54.  *      Where: <actor_id> Represents the variable to store the actor's id
  55.  *             <data> The new profile text you would like to set
  56.  *
  57.  * Just make sure that you're using the correct IDs by checking them in
  58.  * Database before trying to use, in order to avoid unexpected errors.
  59.  *
  60. */
  61.  
  62.       // IMPORTANT: TO_DO, KNOWN ISSUES AND MISC
  63.       // TO-DO: We can do it better for the 3 text functions. Maybe next time!
  64.       // TO-DO: Error checking on variables, give error or default values
  65.       // KNOWN ISSUE: Actor name branch only accept a single name...
  66.  
  67.  
  68.  
  69. //==============================================================================
  70. // ** PARAMETERS, COMMANDS & MISC
  71. //------------------------------------------------------------------------------
  72. //  Let's handle it here and now!
  73. //==============================================================================
  74. (function() {
  75.  
  76.   // Dealing with our commands here
  77.   var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  78.   Game_Interpreter.prototype.pluginCommand = function(command, args) {
  79.       _Game_Interpreter_pluginCommand.call(this, command, args);
  80.  
  81.       // Unless I say otherwise...
  82.       var actor = $gameActors.actor(Number($gameVariables.value(args[0])) || 1);
  83.  
  84.       //Plugin Commands Goes Here
  85.       switch (command) {
  86.         case 'ConditionalBranchActor': // Conditional Branch for Actors
  87.             var value = args[2];
  88.             var result = false;
  89.             switch (args[1]) {
  90.             case 'OnGroup?': // In the Party
  91.                 result = $gameParty.members().contains(actor);
  92.                 break;
  93.             case 'Name': // Name
  94.                 result = (actor.name() === value);
  95.                 break;
  96.             case 'Class': // Class
  97.                 result = actor.isClass($dataClasses[value]);
  98.                 break;
  99.             case 'Skill': // Skill
  100.                 result = actor.isLearnedSkill(value);
  101.                 break;
  102.             case 'Weapon': // Weapon
  103.                 result = actor.hasWeapon($dataWeapons[value]);
  104.                 break;
  105.             case 'Armor': // Armor
  106.                 result = actor.hasArmor($dataArmors[value]);
  107.                 break;
  108.             case 'State': // State
  109.                 result = actor.isStateAffected(value);
  110.                 break;
  111.             }
  112.             $gameSwitches.setValue(args[0], result);
  113.             break;
  114.         case 'ChangeItems': // Change Items, Weapons and Armors
  115.             if (args[0] === 'Items'){
  116.               var data = $dataItems[args[1]];
  117.             } else if (args[0] === 'Weapons'){
  118.               var data = $dataWeapons[args[1]];
  119.             } else if (args[0] === 'Armors'){
  120.               var data = $dataArmors[args[1]];
  121.             }
  122.             var ammount = args[2]
  123.             var inclEquips = args[3];
  124.             $gameParty.gainItem(data, ammount, inclEquips);
  125.             break;
  126.         case 'ChangePartyMember':
  127.             // Change Party Member
  128.             if (args[1] === 'Add') {  // Add
  129.                 $gameParty.addActor(args[0]);
  130.             } else if (args[1] === 'Remove') {  // Remove
  131.                 $gameParty.removeActor(args[0]);
  132.             }
  133.             if (args[2] === true) {   // Initialize, aka Reset
  134.                 $gameActors.actor(args[0]).setup(args[0]);
  135.             }
  136.             break;
  137.         case 'ChangeEquipment': // Change Equipment
  138.             actor.changeEquipById(args[1], args[2]);
  139.         case 'ChangeClass': // Change Class
  140.             actor.changeClass(args[1], false); // Keep EXP?
  141.             break;
  142.         case 'ChangeName': // Change Name
  143.             var c = 0; for (var t in args){ c++; }; c -= 3
  144.             var text = args[1]; // Starting filling
  145.             for (var t = 2; t < c; t++){
  146.               text += ' ' + args[t]; // Fill the remaning
  147.             }
  148.             actor.setName(text);
  149.             break;
  150.         case 'ChangeNickname': // Change Nickname
  151.             var c = 0; for (var t in args){ c++; }; c -= 3
  152.             var text = args[1]; // Starting filling
  153.             for (var t = 2; t < c; t++){
  154.               text += ' ' + args[t]; // Fill the remaning
  155.             }
  156.             actor.setNickname(text);
  157.             break;
  158.         case 'ChangeProfile': // Change Profile
  159.             var c = 0; for (var t in args){ c++; }; c -= 3
  160.             var text = args[1]; // Starting filling
  161.             for (var t = 2; t < c; t++){
  162.               text += ' ' + args[t]; // Fill the remaning
  163.             }
  164.             actor.setProfile(text);
  165.             break;
  166.       } // end of: switch(command)
  167.   }; //end of: function
  168.  
  169. //==============================================================================
  170. // ** END OF CODE
  171. //==============================================================================
  172. })(); //Don't remove this!
Advertisement
Add Comment
Please, Sign In to add comment