Advertisement
jerry2810

ItemCombination

Oct 31st, 2015
408
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ItemCombination.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Creates an item combination system.
  7.  * @author Jeremy Cannady
  8.  *
  9.  *
  10.  * @help creates Item combo system.
  11.  *
  12.  *
  13.  *
  14.     NoteTags
  15.     <comboChance:0.95>      where 0.95 is 95%
  16.     <comboIngredient1:1,1>  where you require one item #1
  17.     <comboIngredient2:2,3>  where you require three of item #2
  18.     <comboFail:4>           If you fail you make item #4
  19.    
  20.     Plugin Commands
  21.     no spaces and the exact format, must have comboChance, at least one ingredient and the combo fail or will crash
  22.     itemComboForget 1       where you forget the recipe to combine item #1 which is a recipe
  23.     itemComboLearn 5        where you learn the recipe to make item #5
  24.     itemComboChanceChange 7,0.5 where you change item# 7 chance to combine to 0.5 which is 50%
  25.     ItemComboMenuEnabled true   where true or false enables the menu option or not
  26.  *
  27.  *
  28. */
  29.  
  30.  
  31.  
  32.  
  33. (function(){
  34.  
  35. var copyOfAddOrginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
  36. Window_MenuCommand.prototype.addOriginalCommands = function() {
  37.     copyOfAddOrginalCommands.call(this)
  38.     var enabled = this.isItemComboEnabled();
  39.     if(enabled){
  40.     this.addCommand('Combine', 'itemCombinationCommand', enabled);
  41. };
  42. };
  43.  
  44. Window_MenuCommand.prototype.isItemComboEnabled = function() {
  45.     if(Game_Party.prototype._craftingLearnedRecipes.length < 1 ){
  46.         return false;
  47.     }else if(Game_Party.prototype._CombineMenuEnabled != true){
  48.         return false;
  49.     }else{
  50.     return true
  51.     };
  52. };
  53.  
  54. Game_Party.prototype._CombineMenuEnabled = true;
  55.  
  56. var copyOfCreateCommandWindow = Scene_Menu.prototype.createCommandWindow;
  57. Scene_Menu.prototype.createCommandWindow = function() {
  58.     copyOfCreateCommandWindow.call(this);
  59.     this._commandWindow.setHandler('itemCombinationCommand',    this.commandCombinationMenu.bind(this));
  60. };
  61.  
  62. Scene_Menu.prototype.commandCombinationMenu = function() {
  63.     SceneManager.push(Scene_CraftingMenu);
  64. };
  65.  
  66. Game_Party.prototype._craftingRecipes = {};
  67.  
  68. var copyOfInitializeCombo = Game_Party.prototype.initialize;
  69.  
  70. Game_Party.prototype.initialize = function() {
  71.     copyOfInitializeCombo.call(this);
  72.     this.populateCraftingRecipes();
  73. };
  74.  
  75. Game_Party.prototype.populateCraftingRecipes = function() {
  76.     var lengthOfItemList = $dataItems.length;
  77.        
  78.     for(var i = 1; i < lengthOfItemList; i++){
  79.     var ingredientArray = [];
  80.  
  81.     if(typeof $dataItems[i].meta.comboChance !== "undefined"){
  82.             ingredientArray.push(Number($dataItems[i].id));
  83.             ingredientArray.push(Number($dataItems[i].meta.comboChance));
  84.             ingredientArray.push(Number($dataItems[i].meta.comboFail));
  85.         };
  86.         if(typeof $dataItems[i].meta.comboIngredient1 !== "undefined"){
  87.             var ingredientArrayIngredient = $dataItems[i].meta.comboIngredient1.split(',');
  88.             for(var j=0; j<2; j++) {
  89.             ingredientArrayIngredient[j] = parseInt(ingredientArrayIngredient[j], 10);};
  90.             ingredientArray.push(ingredientArrayIngredient);
  91.         };
  92.         if(typeof $dataItems[i].meta.comboIngredient2 !== "undefined"){
  93.             var ingredientArrayIngredient = $dataItems[i].meta.comboIngredient2.split(',');
  94.             for(var j=0; j<2; j++) {
  95.             ingredientArrayIngredient[j] = parseInt(ingredientArrayIngredient[j], 10);};
  96.             ingredientArray.push(ingredientArrayIngredient);
  97.         };
  98.         if(typeof $dataItems[i].meta.comboIngredient3 !== "undefined"){
  99.             var ingredientArrayIngredient = $dataItems[i].meta.comboIngredient3.split(',');
  100.             for(var j=0; j<2; j++) {
  101.             ingredientArrayIngredient[j] = parseInt(ingredientArrayIngredient[j], 10);};
  102.             ingredientArray.push(ingredientArrayIngredient);
  103.         };
  104.         if(typeof $dataItems[i].meta.comboIngredient4 !== "undefined"){
  105.             var ingredientArrayIngredient = $dataItems[i].meta.comboIngredient4.split(',');
  106.             for(var j=0; j<2; j++) {
  107.             ingredientArrayIngredient[j] = parseInt(ingredientArrayIngredient[j], 10);};
  108.             ingredientArray.push(ingredientArrayIngredient);
  109.         };
  110.         if(typeof $dataItems[i].meta.comboIngredient5 !== "undefined"){
  111.             var ingredientArrayIngredient = $dataItems[i].meta.comboIngredient5.split(',');
  112.             for(var j=0; j<2; j++) {
  113.             ingredientArrayIngredient[j] = parseInt(ingredientArrayIngredient[j], 10);};
  114.             ingredientArray.push(ingredientArrayIngredient);
  115.         };
  116.        
  117.         if(typeof $dataItems[i].meta.comboChance !== "undefined"){
  118.         Game_Party.prototype._craftingRecipes[$dataItems[i].name] = ingredientArray;
  119.         }
  120.         else{} 
  121.         };     
  122. };
  123.  
  124. Game_Party.prototype._craftingLearnedRecipes = [];
  125.  
  126. Game_Party.prototype.canCombine = function(value){
  127.     var recipeKeyName = value;
  128.     var ingredientArray = Game_Party.prototype.ingredients(recipeKeyName);
  129.     var numberOfRequiredIngredients = ingredientArray.length;
  130.  
  131.     var ingredientArrayNames = [];
  132.     var recipe = $dataItems[itemNumber]
  133.  
  134.     var haveAllIngredients = 0;
  135.    
  136.         for(i =0;i< numberOfRequiredIngredients;i++){
  137.        
  138.             var itemNumber = ingredientArray[i][0];
  139.             var requiredAmount = ingredientArray[i][1];
  140.             var ingredient = $dataItems[itemNumber];
  141.  
  142.             ingredientArrayNames.push(ingredient);
  143.             if ($gameParty.numItems(ingredient) >= requiredAmount){
  144.                 haveAllIngredients += 1;
  145.             };
  146.         };
  147.             if(haveAllIngredients == numberOfRequiredIngredients){
  148.                 return true;
  149.             }
  150.             else{
  151.             return false;
  152.             };
  153. };
  154.  
  155. Game_Party.prototype.learnRecipe = function(value) {
  156.     if(this._craftingLearnedRecipes.indexOf(value) === -1){
  157.         this._craftingLearnedRecipes.push(value);
  158.     };
  159. };
  160.  
  161. Game_Party.prototype.forgetRecipe = function(value) {
  162.     //Stores the value of the index, if the value is -1 then we do not have the recipe.
  163.     var index = this._craftingLearnedRecipes.indexOf(value);
  164.     //If we do have the recipe learned then delete it from out learned recipes list.
  165.     if(this._craftingLearnedRecipes.indexOf(value) != -1){
  166.         this._craftingLearnedRecipes.splice(index,1);
  167.     };
  168. };
  169.  
  170. Game_Party.prototype.changeItemComboChance = function(recipeName, newChance) {
  171.     var recipeDetails = Game_Party.prototype._craftingRecipes[recipeName];
  172.     recipeDetails[1] = newChance;
  173. };
  174.  
  175. Game_Party.prototype.ingredients = function(recipeKeyName){
  176.     var recipeDetails = Game_Party.prototype._craftingRecipes[recipeKeyName];
  177.     var numberOfIngredients = recipeDetails.length;
  178.     var ingredientsList =[];
  179.     for(i = 3; i < numberOfIngredients; i++){
  180.         var itemNumber = recipeDetails[i];
  181.         ingredientsList.push(itemNumber);
  182.     };
  183.     return ingredientsList;
  184. };
  185.  
  186. function craftingTitleWindow() {
  187.     this.initialize.apply(this, arguments);
  188. };
  189.  
  190. craftingTitleWindow.prototype = Object.create(Window_Base.prototype);
  191. craftingTitleWindow.prototype.constructor = craftingTitleWindow;
  192.  
  193. craftingTitleWindow.prototype.initialize = function(x, y) {
  194.     var width = this.windowWidth();
  195.     var height = this.windowHeight();
  196.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  197.     this.update();
  198. };
  199.  
  200. craftingTitleWindow.prototype.windowWidth = function() {
  201.     return 816;
  202. };
  203.  
  204. craftingTitleWindow.prototype.windowHeight = function() {
  205.     return this.fittingHeight(1);
  206. };
  207.  
  208. craftingTitleWindow.prototype.drawCraftingTitle = function( x, y, width) {
  209.     var unitWidth = Math.min(80);
  210.     this.resetTextColor();
  211.     this.drawText("Item Combination Menu", x, y, width - unitWidth - 6, 'left');
  212.     this.changeTextColor(this.systemColor());
  213.    };
  214.    
  215. craftingTitleWindow.prototype.update = function() {
  216.     var x = this.textPadding();
  217.     var width = this.contents.width - this.textPadding() * 2;
  218.     this.contents.clear();
  219.     this.drawCraftingTitle( 0, 0, width);
  220.  
  221. };
  222.  
  223. craftingTitleWindow.prototype.open = function() {
  224.     this.update();
  225.     Window_Base.prototype.open.call(this);
  226. };
  227.  
  228. function craftingListWindow() {
  229.     this.initialize.apply(this, arguments);
  230. }
  231.  
  232. craftingListWindow.prototype = Object.create(Window_Command.prototype);
  233. craftingListWindow.prototype.constructor = craftingListWindow;
  234. craftingListWindow.prototype.canCombine = false;
  235.  
  236. craftingListWindow.prototype.initialize = function(x, y) {
  237.     Window_Command.prototype.initialize.call(this, x, y);
  238.     this.selectLast();
  239. };
  240.  
  241. craftingListWindow.prototype.update = function() {
  242.     Window_Command.prototype.update.call(this);
  243.  
  244.  };
  245.  
  246. craftingListWindow.initCommandPosition = function() {
  247.     this._lastCommandSymbol = null;
  248. };
  249.  
  250. craftingListWindow.prototype.windowWidth = function() {
  251.     return 240;
  252. };
  253.  
  254. craftingListWindow.prototype.windowHeight = function() {
  255.     return 552;
  256. };
  257.  
  258. craftingListWindow.prototype.numVisibleRows = function() {
  259.     return this.maxItems();
  260. };
  261.  
  262. craftingListWindow.prototype.makeCommandList = function() {
  263.     this.addOriginalCommands();
  264. };
  265.  
  266. craftingListWindow.prototype.addOriginalCommands = function() {
  267.     var numberOfLearnedRecipes = Game_Party.prototype._craftingLearnedRecipes;
  268.  
  269.     for(var i = 0; i < numberOfLearnedRecipes.length; i++){
  270.         var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[i];
  271.         var enabled = Game_Party.prototype.canCombine(recipeKeyName);
  272.         var recipeDetails = Game_Party.prototype._craftingRecipes[recipeKeyName];
  273.         var itemNumber = recipeDetails[0];
  274.         var recipeName = $dataItems[itemNumber];
  275.         this.addCommand(recipeName.name, recipeName.name, enabled);
  276.     };
  277.  };
  278.  
  279. craftingListWindow.prototype.isCurrentItemEnabled = function(){
  280.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[craftingDetailsWindow.prototype.currentItemIndex];
  281.     var enabled = Game_Party.prototype.canCombine(recipeKeyName)
  282.     return enabled;
  283. };
  284.  
  285. craftingListWindow.prototype.processOk = function() {
  286.     craftingListWindow._lastCommandSymbol = this.currentSymbol();
  287.     Window_Command.prototype.processOk.call(this);
  288. };
  289.  
  290. craftingListWindow.prototype.selectLast = function() {
  291.     this.selectSymbol(craftingListWindow._lastCommandSymbol);
  292. };
  293.  
  294. function craftingDetailsWindow() {
  295.     this.initialize.apply(this, arguments);
  296. };
  297.  
  298. craftingDetailsWindow.prototype = Object.create(Window_Command.prototype);
  299.  
  300. craftingDetailsWindow.prototype.constructor = craftingDetailsWindow;
  301. craftingDetailsWindow.prototype.currentItemIndex = 0;
  302.  
  303. craftingDetailsWindow.prototype.initialize = function(x, y) {
  304.     Window_Command.prototype.initialize.call(this, x, y);
  305.     this.deactivate();
  306.     this.deselect();
  307. };
  308.  
  309. craftingDetailsWindow.prototype.windowWidth = function() {
  310.     return 576;
  311. };
  312.  
  313. craftingDetailsWindow.prototype.windowHeight = function() {
  314.     return 552;
  315. };
  316.  
  317. craftingDetailsWindow.prototype.update = function() {
  318.     Window_Command.prototype.update.call(this);
  319.     this.contents.clear();
  320.     this.drawDetailsName(0, 0, this.windowWidth());
  321.     this.drawDetailsDescription(0, 100, this.windowWidth());
  322.     this.drawIngredient(0,200-28,this.windowWidth()/2);
  323.     this.drawComboChance(0,400,this.windowWidth());
  324.     this.drawDetailsIngredients(0, 200, this.windowWidth()/2);
  325.     this.drawItem(0);
  326. };
  327.  
  328. craftingDetailsWindow.prototype.maxItems = function() {
  329.     return 1;
  330. };
  331.  
  332. craftingDetailsWindow.prototype.maxCols = function(){
  333. return 1;
  334. };
  335.  
  336. craftingDetailsWindow.prototype.itemRect = function(index) {
  337.     var rect = new Rectangle();
  338.     var maxCols = this.maxCols();
  339.     rect.width = this.textWidth('Combine');
  340.     rect.height = this.itemHeight();
  341.     rect.x = this.windowWidth()/2-rect.width+32;
  342.     rect.y = 450;
  343.     return rect;
  344. };
  345.  
  346. craftingDetailsWindow.prototype.drawDetailsName = function(x, y, width) {
  347.     this.resetTextColor();
  348.     var unitWidth = Math.min(80);
  349.  
  350.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[this.currentItemIndex];
  351.     var recipeDetails = Game_Party.prototype._craftingRecipes[recipeKeyName];
  352.    
  353.     var itemNumber = recipeDetails[0];
  354.     var recipe = $dataItems[itemNumber]
  355.    
  356.     this.drawText(recipe.name, x, y, this.windowWidth() -32, 'center');
  357.     this.changeTextColor(this.systemColor());
  358.     this.drawIcon(recipe.iconIndex, this.windowWidth()/2-32, y+50);
  359. };
  360.  
  361. craftingDetailsWindow.prototype.drawIngredient = function(x, y, width) {
  362.     this.resetTextColor();
  363.     var unitWidth = Math.min(80);
  364.     this.drawText('Required Ingredients :', x+50, y, width - unitWidth, 'center');
  365.     this.changeTextColor(this.systemColor());
  366. };
  367.  
  368. craftingDetailsWindow.prototype.drawComboChance = function(x, y, width) {
  369.     this.resetTextColor();
  370.     var unitWidth = Math.min(80);
  371.  
  372.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[this.currentItemIndex];
  373.     var recipeDetails = Game_Party.prototype._craftingRecipes[recipeKeyName];
  374.    
  375.     var chance = recipeDetails[1] * 100;
  376.  
  377.     if(chance>75){
  378.     this.changeTextColor(this.textColor(3))}
  379.     else if(chance > 50){this.changeTextColor(this.textColor(14))}
  380.     else if(chance > 25){this.changeTextColor(this.textColor(20))}
  381.     else {this.changeTextColor(this.textColor(10))};
  382.    
  383.     var unitWidth = Math.min(80);
  384.     this.drawText(chance + ' %', x, y, this.windowWidth() - 32 , 'center');
  385.     this.changeTextColor(this.systemColor());
  386. };
  387.  
  388. craftingDetailsWindow.prototype.drawDetailsDescription = function(x, y, width) {
  389.     var unitWidth = Math.min(80);
  390.     this.resetTextColor();
  391.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[craftingDetailsWindow.prototype.currentItemIndex];
  392.     var recipeDetails = Game_Party.prototype._craftingRecipes[recipeKeyName];
  393.     var itemNumber = recipeDetails[0];
  394.     var recipe = $dataItems[itemNumber]
  395.     var enabled = Game_Party.prototype.canCombine(recipeKeyName);
  396.     this.changePaintOpacity(enabled);
  397.     this.drawText(recipe.description, x, y, width - 32, 'center');
  398.     this.changeTextColor(this.systemColor());
  399. };
  400.  
  401. craftingDetailsWindow.prototype.isCurrentItemEnabled = function(){
  402.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[craftingDetailsWindow.prototype.currentItemIndex];
  403.     var enabled = Game_Party.prototype.canCombine(recipeKeyName)
  404.     return enabled;
  405.  
  406. };
  407.  
  408. craftingDetailsWindow.prototype.drawDetailsIngredients = function(x, y, width) {
  409.     var unitWidth = Math.min(80);
  410.     this.resetTextColor();
  411.     var inIntialY = y;
  412.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[craftingDetailsWindow.prototype.currentItemIndex];
  413.     var ingredientArray = Game_Party.prototype.ingredients(recipeKeyName);
  414.     var numberOfRequiredIngredients = ingredientArray.length;
  415.    
  416.     var ingredientArrayNames = [];
  417.     var recipe = $dataItems[itemNumber]
  418.     var spacing = 32;
  419.     var haveAllIngredients = 0;
  420.    
  421.         for(i =0;i< numberOfRequiredIngredients;i++){
  422.             var y = inIntialY + spacing*i;
  423.             var itemNumber = ingredientArray[i][0];
  424.             var requiredAmount = ingredientArray[i][1];
  425.             var ingredient = $dataItems[itemNumber];
  426.  
  427.             ingredientArrayNames.push(ingredient);
  428.             if ($gameParty.numItems(ingredient) >= requiredAmount){
  429.                 haveAllIngredients += 1;
  430.                 this.resetTextColor();
  431.             }
  432.             else{
  433.             this.changeTextColor(this.hpGaugeColor1())}
  434.             this.drawText($gameParty.numItems(ingredient), x+64, y, width, 'right');
  435.             this.drawIcon(ingredient.iconIndex, this.windowWidth() / 2 - 32 , y);
  436.             this.drawText('/ ' + requiredAmount, x +this.textWidth('0')+64, y, width + this.textWidth('00') , 'right');
  437.             this.drawText(ingredient.name, x +this.textWidth('00'), y, width - unitWidth - 18, 'right');
  438.             };
  439.  
  440.         this.changeTextColor(this.systemColor());
  441. };
  442.  
  443. craftingDetailsWindow.prototype.drawItem = function(index){
  444.     var rect = this.itemRectForText(index);
  445.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[craftingDetailsWindow.prototype.currentItemIndex];
  446.     var enabled = Game_Party.prototype.canCombine(recipeKeyName);
  447.     this.resetTextColor();
  448.     this.addCommand("Combine", "Combine", enabled);
  449.     this.drawText(this.commandName(index), rect.x , rect.y, rect.width, 'center')
  450.     this.resetTextColor();
  451. };
  452.  
  453. craftingDetailsWindow.prototype.processOk = function() {
  454.     craftingDetailsWindow._lastCommandSymbol = this.currentSymbol();
  455.     Window_Command.prototype.processOk.call(this);
  456. };
  457.  
  458. craftingDetailsWindow.prototype.selectLast = function() {
  459.     this.selectSymbol(craftingDetailsWindow._lastCommandSymbol);
  460. };
  461.  
  462. function Scene_CraftingMenu() {
  463.     this.initialize.apply(this, arguments);
  464. }
  465. Scene_CraftingMenu.prototype = Object.create(Scene_MenuBase.prototype);
  466. Scene_CraftingMenu.prototype.constructor = Scene_CraftingMenu;
  467.  
  468. Scene_CraftingMenu.prototype.initialize = function() {
  469.     Scene_MenuBase.prototype.initialize.call(this);
  470. };
  471.  
  472. Scene_CraftingMenu.prototype.update = function() {
  473.     Scene_MenuBase.prototype.update.call(this);
  474.     this.updateDetails();
  475. };
  476.  
  477. Scene_CraftingMenu.prototype.updateDetails = function(){
  478.     if(this._commandItemWindow.active){
  479.         craftingDetailsWindow.prototype.currentItemIndex = this._commandItemWindow.index();
  480.     };
  481. };
  482.  
  483. Scene_CraftingMenu.prototype.create = function() {
  484.    Scene_MenuBase.prototype.create.call(this);
  485.    this.createTitleWindow();
  486.    this.createCommandWindow();
  487.    this.createDetailsWindow();
  488. };
  489.  
  490. Scene_CraftingMenu.prototype.start = function() {
  491.     Scene_MenuBase.prototype.start.call(this);
  492. };
  493.    
  494. Scene_CraftingMenu.prototype.createCommandWindow = function() {
  495.     var y = craftingTitleWindow.prototype.windowHeight();
  496.     this._commandItemWindow = new craftingListWindow(0, y);
  497.     this._commandItemWindow.setHandler('ok',        this.commandDetails.bind(this));
  498.     this._commandItemWindow.setHandler('cancel',    this.popScene.bind(this));
  499.     this.addWindow(this._commandItemWindow);
  500. };
  501.  
  502. Scene_CraftingMenu.prototype.createDetailsWindow = function() {
  503.     var x = craftingListWindow.prototype.windowWidth();
  504.     var y = craftingTitleWindow.prototype.windowHeight();
  505.     this._commandDetailsWindow = new craftingDetailsWindow(x, y);
  506.     this.addWindow(this._commandDetailsWindow );
  507. };
  508.  
  509. Scene_CraftingMenu.prototype.createTitleWindow = function() {
  510.     this._craftingTitleWindow = new craftingTitleWindow(0, 0);
  511.     this.addWindow(this._craftingTitleWindow);
  512. };
  513.  
  514. Scene_CraftingMenu.prototype.commandDetails = function() {
  515.     this._commandDetailsWindow.selectLast();
  516.     this._commandItemWindow.deselect();
  517.     this._commandDetailsWindow.activate();
  518.     this._commandDetailsWindow .setHandler('ok',        this.onDetailsOk.bind(this));
  519.     this._commandDetailsWindow .setHandler('cancel',    this.onDetailsCancel.bind(this));
  520. };
  521.  
  522. Scene_CraftingMenu.prototype.onDetailsOk = function() {
  523.     var recipeKeyName = Game_Party.prototype._craftingLearnedRecipes[craftingDetailsWindow.prototype.currentItemIndex];
  524.     var ingredientArray = Game_Party.prototype.ingredients(recipeKeyName);
  525.     var numberOfRequiredIngredients = ingredientArray.length;
  526.     var recipeDetails = Game_Party.prototype._craftingRecipes[recipeKeyName];
  527.     var ingredientArrayNames = [];
  528.     var itemNumber = recipeDetails[0];
  529.     var recipe = $dataItems[itemNumber];
  530.     var fail = $dataItems[recipeDetails[2]];
  531.     var enabled = Game_Party.prototype.canCombine(recipeKeyName)
  532.    
  533.     if(enabled){
  534.         for(i =0;i< numberOfRequiredIngredients;i++){
  535.             var itemNumber = ingredientArray[i][0];
  536.             var requiredAmount = ingredientArray[i][1];
  537.             var ingredient = $dataItems[itemNumber];
  538.             $gameParty.loseItem(ingredient, requiredAmount);
  539.         };
  540.     var rng = Math.random();
  541.     var chance = recipeDetails[1];
  542.     if(rng < chance){
  543.     $gameParty.gainItem(recipe, 1);
  544.     }
  545.     else{
  546.     $gameParty.gainItem(fail, 1);
  547.     SoundManager.playBuzzer();
  548.     };
  549.     };
  550.    
  551.     SceneManager.goto(Scene_CraftingMenu);
  552. };
  553.  
  554. Scene_CraftingMenu.prototype.onDetailsCancel = function() {
  555.     this._commandItemWindow.selectLast();
  556.     this._commandItemWindow.activate();
  557. };
  558.  
  559. var comboMenuEnabled_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  560. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  561.     comboMenuEnabled_pluginCommand.call(this, command, args);
  562.     if (command === "ItemComboMenuEnabled") {
  563.     Game_Party.prototype._CombineMenuEnabled = JSON.parse(args[0]);
  564.     };
  565. };
  566.  
  567. var itemComboLearn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  568. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  569.     itemComboLearn_pluginCommand.call(this, command, args);
  570.     if (command === "itemComboLearn") {
  571.         var arg = $dataItems[JSON.parse(args[0])].name;
  572.         $gameParty.learnRecipe(arg);
  573.     };
  574. };
  575.  
  576. var itemComboChance_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  577. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  578.     itemComboChance_pluginCommand.call(this, command, args);
  579.     if (command === "itemComboChanceChange") {
  580.         var arg1 = $dataItems[JSON.parse(args[0])].name;
  581.         var arg2 = JSON.parse(args[1]);
  582.         $gameParty.changeItemComboChance(arg1,arg2);
  583.     };
  584. };
  585.  
  586. var itemComboForget_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  587. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  588.     itemComboForget_pluginCommand.call(this, command, args);
  589.     if (command === "itemComboForget") {
  590.         var arg = $dataItems[JSON.parse(args[0])].name;
  591.         $gameParty.forgetRecipe(arg);
  592.     };
  593. };
  594. }());
Advertisement
RAW Paste Data Copied
Advertisement