Guest User

STV_SimpleBeastBook

a guest
Nov 7th, 2016
401
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // STV_SimpleBeastBook.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc v1.1 - STV_SimpleBeastBook
  7.  * || This will add a Simple Beast Register to your Game.
  8.  * @author SkottyTV
  9.  *
  10.  * @param --- Functions ---
  11.  *
  12.  * @param Fill Behavior
  13.  * @desc How the Book will get filled.
  14.  * 1 = Encounter / 2 = Kill / 3 = None (only commands)
  15.  * @default 2
  16.  *
  17.  * @param Max Cat Cols
  18.  * @desc The Maximum Categorys visible at once.
  19.  * @default 4
  20.  *
  21.  * @param Show ID
  22.  * @desc Show ID in front of a Beast.
  23.  * (Show = TRUE / Hide = FALSE)
  24.  * @default TRUE
  25.  *
  26.  * @param --- Font Size ---
  27.  *
  28.  * @param Font Size Cat
  29.  * @desc Font Size of the Category Window
  30.  * @default 24
  31.  *
  32.  * @param Font Size Beasts
  33.  * @desc Font Size of the Category Window
  34.  * @default 16
  35.  *
  36.  * @param Font Size Info
  37.  * @desc Font Size of the Category Window
  38.  * @default 16
  39.  *
  40.  * @param ----- Text -----
  41.  *
  42.  * @param Unknown Text
  43.  * @desc The default Text for unknown data.
  44.  * @default ?????
  45.  *
  46.  * @param Description Text
  47.  * @desc The default Text for "Description:"
  48.  * (NO FUNCTION!)
  49.  * @default Description:
  50.  *
  51.  *
  52.  * @help
  53.  *
  54.  * ////////////////////////////////////////////////////////////////////////////
  55.  * ----------------------------- Terms of Usage: ------------------------------
  56.  * ////////////////////////////////////////////////////////////////////////////
  57.  
  58.  * Feel free to use this Plugin in 1. Non-Commercial Games, 2. Commercial Games
  59.  * However it would be nice to give proper Credits to "SkottyTV"
  60.  * Also a free copy of your Game would be a nice move :)
  61.  *
  62.  * Have Fun And Enjoy! :)
  63.  *
  64.  *
  65.  *
  66.  * ////////////////////////////////////////////////////////////////////////////
  67.  * --------------------------------- Updates:----------------------------------
  68.  * ////////////////////////////////////////////////////////////////////////////
  69.  *
  70.  * Update v1.0
  71.  * - Basic Functionality.
  72.  *
  73.  * Update v1.1
  74.  * - Added Font Size customization.
  75.  * - Changed Window Positions.
  76.  *
  77.  * ////////////////////////////////////////////////////////////////////////////
  78.  * -------------------------------- Commands: ---------------------------------
  79.  * ////////////////////////////////////////////////////////////////////////////
  80.  *
  81.  * Plugin Command:
  82.  *   SimpleBeastBook open           # Open the beast book screen.
  83.  *   SimpleBeastBook discover 3     # Discover enemy #3 in the beast book.
  84.  *
  85.  * Enemy Note:
  86.  *   <desc1:The mighty Clown>   # Description text in the Beast Book, line 1
  87.  *   <STVSBB Cat: Normal>       # Creates the Category "Normal" and determine
  88.  *                                this Beast to it.
  89.  *   <STVSBB Pic: Normal>       # Name of the default Picture for the Beast.
  90.  *                                Picture has to be under "img/enemies".
  91.  *                                Without this line the default picture is used.
  92.  *   <STVSBB Desc>              # Start of the Beast Description.
  93.  *   This is a Bat.             # Simple Text Description.
  94.  *   It has \i[5]Wings.         # Description Line with Icon.
  95.  *   It sucks \c[2]Blood.       # Description Line with colored Text.
  96.  *   </STVSBB Desc>             # End of the Beast Description.
  97.  *
  98.  */
  99.  
  100.  
  101. // ----------------------------------------------------------------------------------------------------------------------------
  102. // STV_BeastBook Parameters
  103. // ----------------------------------------------------------------------------------------------------------------------------
  104.     var stv_SimpleBeastBook_parameters = PluginManager.parameters('STV_SimpleBeastBook');
  105.    
  106.     //--- Functions ---
  107.     var stv_SimpleBeastBook_fillBehavior = Number(stv_SimpleBeastBook_parameters['Fill Behavior'] || 2);
  108.     var stv_SimpleBeastBook_maxCols = Number(stv_SimpleBeastBook_parameters['Max Cat Cols'] || 4);
  109.     var stv_SimpleBeastBook_showId = String(stv_SimpleBeastBook_parameters['Show ID'] || "TRUE");
  110.    
  111.     //--- Font Size ---
  112.     var stv_SimpleBeastBook_fontSizeCat = Number(stv_SimpleBeastBook_parameters['Font Size Cat'] || 24);
  113.     var stv_SimpleBeastBook_fontSizeBeasts = Number(stv_SimpleBeastBook_parameters['Font Size Beasts'] || 16);
  114.     var stv_SimpleBeastBook_fontSizeInfo = Number(stv_SimpleBeastBook_parameters['Font Size Info'] || 16);
  115.    
  116.     //----- Text -----
  117.     var stv_SimpleBeastBook_unknown = String(stv_SimpleBeastBook_parameters['Unknown Text'] || "?????");
  118.     //var stv_SimpleBeastBook_descText = String(stv_SimpleBeastBook_parameters['Description Text'] || "Description:");
  119.  
  120. // ----------------------------------------------------------------------------------------------------------------------------
  121. // Scene SimpleBeastBook create
  122. // ----------------------------------------------------------------------------------------------------------------------------  
  123.     Scene_SimpleBeastBook = function() {
  124.         this.initialize.apply(this, arguments);
  125.     };
  126.  
  127.     Scene_SimpleBeastBook.prototype = Object.create(Scene_MenuBase.prototype);
  128.     Scene_SimpleBeastBook.prototype.constructor = Scene_SimpleBeastBook;
  129.  
  130.     Scene_SimpleBeastBook.prototype.initialize = function() {
  131.         Scene_MenuBase.prototype.initialize.call(this);
  132.         this._switch = false;
  133.     };                                                          
  134.    
  135.     Scene_SimpleBeastBook.prototype.create = function() {
  136.         Scene_MenuBase.prototype.create.call(this);
  137.        
  138.         this.createWindowPositions();
  139.         this.createCatWindow();
  140.         this.createBeastsWindow();
  141.         this.createSpriteWindow();
  142.         this.createInfoWindow();
  143.     };
  144.    
  145. // ----------------------------------------------------------------------------------------------------------------------------
  146. // Create Window Positions
  147. // ----------------------------------------------------------------------------------------------------------------------------
  148.     Scene_SimpleBeastBook.prototype.createWindowPositions = function() {
  149.         var maxWidth = Graphics.boxWidth,
  150.             maxHeight = Graphics.boxHeight;
  151.        
  152.         var cX = 0,
  153.             cY = 0,
  154.             cW = maxWidth,
  155.             cH = 72;
  156.         this._catWindow = new Window_SimpleBeastBook_Category(cX, cY, cW, cH);
  157.        
  158.         var bX = cX,
  159.             bY = cH,
  160.             bW = (maxWidth/3),
  161.             bH = maxHeight - cH;
  162.         this._beastsWindow = new Window_SimpleBeastBook_Beasts(bX, bY, bW, bH);
  163.        
  164.         var sX = bW,
  165.             sY = bY,
  166.             sW = maxWidth - bW,
  167.             sH = bH / 2;
  168.         this._spriteWindow = new Window_SimpleBeastBook_Sprite(sX, sY, sW, sH);
  169.        
  170.         var iX = sX,
  171.             iY = sY + sH,
  172.             iW = sW,
  173.             iH = sH;
  174.         this._infoWindow = new Window_SimpleBeastBook_Info(iX, iY, iW, iH);
  175.     };
  176.  
  177. // ----------------------------------------------------------------------------------------------------------------------------
  178. // Create Category Window
  179. // ----------------------------------------------------------------------------------------------------------------------------
  180.     Scene_SimpleBeastBook.prototype.createCatWindow = function() {
  181.         this._catWindow.setHandler('ok', this.onCatSelect.bind(this));
  182.         this._catWindow.setHandler('cancel', this.onCatCancel.bind(this));
  183.         this._catWindow.setBeastsWindow(this._beastsWindow);
  184.         this.addWindow(this._catWindow);
  185.     };
  186.    
  187. // ----------------------------------------------------------------------------------------------------------------------------
  188. // Create Beasts Window
  189. // ----------------------------------------------------------------------------------------------------------------------------
  190.     Scene_SimpleBeastBook.prototype.createBeastsWindow = function() {
  191.         this._beastsWindow.setHandler('ok', this.onBeastSelect.bind(this));
  192.         this._beastsWindow.setHandler('cancel', this.onBeastCancel.bind(this));
  193.         this._beastsWindow.setInfoWindows(this._spriteWindow, this._infoWindow);
  194.         this.addWindow(this._beastsWindow);
  195.         this._beastsWindow.hide();
  196.     };
  197.  
  198. // ----------------------------------------------------------------------------------------------------------------------------
  199. // Create Info Window
  200. // ----------------------------------------------------------------------------------------------------------------------------
  201.     Scene_SimpleBeastBook.prototype.createSpriteWindow = function() {
  202.         this.addWindow(this._spriteWindow);
  203.         this._spriteWindow.opacity = 0;
  204.         this._spriteWindow.hide();
  205.     };
  206.    
  207. // ----------------------------------------------------------------------------------------------------------------------------
  208. // Create Info Window
  209. // ----------------------------------------------------------------------------------------------------------------------------
  210.     Scene_SimpleBeastBook.prototype.createInfoWindow = function() {
  211.         this.addWindow(this._infoWindow);
  212.         this._infoWindow.hide();
  213.     };
  214.    
  215. // ----------------------------------------------------------------------------------------------------------------------------
  216. // On Cat Select
  217. // ----------------------------------------------------------------------------------------------------------------------------
  218.     Scene_SimpleBeastBook.prototype.onCatSelect = function() {
  219.         this._catWindow.deactivate();
  220.         this._beastsWindow.show();
  221.         this._spriteWindow.show();
  222.         this._beastsWindow.activate();
  223.     };
  224.    
  225. // ----------------------------------------------------------------------------------------------------------------------------
  226. // On Cat Cancel
  227. // ----------------------------------------------------------------------------------------------------------------------------
  228.     Scene_SimpleBeastBook.prototype.onCatCancel = function() {
  229.         this.popScene();
  230.     };
  231.    
  232. // ----------------------------------------------------------------------------------------------------------------------------
  233. // On Beast Select
  234. // ----------------------------------------------------------------------------------------------------------------------------
  235.     Scene_SimpleBeastBook.prototype.onBeastSelect = function() {
  236.         if (!this._switch) {
  237.             this._infoWindow.show();
  238.         } else {
  239.             this._infoWindow.hide();
  240.         }
  241.         this._switch = !this._switch;
  242.         this._beastsWindow.activate();
  243.     };
  244.    
  245. // ----------------------------------------------------------------------------------------------------------------------------
  246. // On Beast Cancel
  247. // ----------------------------------------------------------------------------------------------------------------------------
  248.     Scene_SimpleBeastBook.prototype.onBeastCancel = function() {
  249.         if (this._switch) {
  250.             this._infoWindow.hide();
  251.             this._beastsWindow.activate();
  252.             this._switch = !this._switch;
  253.         } else {
  254.             this._beastsWindow.select(0);
  255.             this._beastsWindow.deactivate();
  256.             this._beastsWindow.hide();
  257.             this._spriteWindow.hide();
  258.             this._infoWindow.hide();
  259.             this._catWindow.activate();  
  260.         }
  261.     };
  262.    
  263. // ----------------------------------------------------------------------------------------------------------------------------
  264. // Fill Cat Window
  265. // ----------------------------------------------------------------------------------------------------------------------------
  266.     function Window_SimpleBeastBook_Category() {
  267.         this.initialize.apply(this, arguments);
  268.     }
  269.  
  270.     Window_SimpleBeastBook_Category.prototype = Object.create(Window_HorzCommand.prototype);
  271.     Window_SimpleBeastBook_Category.prototype.constructor = Window_SimpleBeastBook_Category;
  272.  
  273.     Window_SimpleBeastBook_Category.prototype.initialize = function(x, y, width, height) {
  274.         Window_HorzCommand.prototype.initialize.call(this, x, y, width, height);
  275.     };
  276.    
  277.     Window_SimpleBeastBook_Category.prototype.standardFontSize = function() {
  278.         return stv_SimpleBeastBook_fontSizeCat;
  279.     };
  280.  
  281.     Window_SimpleBeastBook_Category.prototype.maxCols = function() {
  282.         if ($simpleBeastBook.beasts[0].length >= stv_SimpleBeastBook_maxCols) {
  283.             return stv_SimpleBeastBook_maxCols;
  284.         } else {
  285.             return $simpleBeastBook.beasts[0].length;
  286.         }
  287.     };
  288.    
  289.     Window_SimpleBeastBook_Category.prototype.windowWidth = function() {
  290.         return Graphics.boxWidth;
  291.     };
  292.    
  293.     Window_SimpleBeastBook_Category.prototype.windowHeight = function() {
  294.         return 72;
  295.     };
  296.    
  297.     Window_SimpleBeastBook_Category.prototype.setBeastsWindow = function(window1) {
  298.         this._beastsWindow = window1;
  299.         this.updateStatus();
  300.     };
  301.    
  302.     Window_SimpleBeastBook_Category.prototype.update = function() {
  303.         Window_Selectable.prototype.update.call(this);
  304.         this.updateStatus();
  305.     };
  306.    
  307.     Window_SimpleBeastBook_Category.prototype.updateStatus = function() {
  308.         var cat = this._list[this.index()].name;
  309.         if (this._beastsWindow) this._beastsWindow.setCat(cat);
  310.     };
  311.    
  312.     Window_SimpleBeastBook_Category.prototype.makeCommandList = function() {
  313.         var cats = $simpleBeastBook.beasts[0];
  314.         for (var i = 0; i < cats.length; ++i) {
  315.             this.addCommand(cats[i], 'ok');
  316.         }
  317.     };
  318.  
  319. // ----------------------------------------------------------------------------------------------------------------------------
  320. // Fill Beasts Window
  321. // ----------------------------------------------------------------------------------------------------------------------------
  322.     function Window_SimpleBeastBook_Beasts() {
  323.         this.initialize.apply(this, arguments);
  324.     }
  325.  
  326.     Window_SimpleBeastBook_Beasts.prototype = Object.create(Window_Selectable.prototype);
  327.     Window_SimpleBeastBook_Beasts.prototype.constructor = Window_SimpleBeastBook_Beasts;
  328.  
  329.     Window_SimpleBeastBook_Beasts.lastTopRow = 0;
  330.     Window_SimpleBeastBook_Beasts.lastIndex  = 0;
  331.  
  332.     Window_SimpleBeastBook_Beasts.prototype.initialize = function(x, y, width, height) {
  333.         Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  334.        
  335.         this.refresh();
  336.         this.setTopRow(Window_SimpleBeastBook_Beasts.lastTopRow);
  337.         this.select(Window_SimpleBeastBook_Beasts.lastIndex);
  338.     };
  339.    
  340.     Window_SimpleBeastBook_Beasts.prototype.standardFontSize = function() {
  341.         return stv_SimpleBeastBook_fontSizeBeasts;
  342.     };
  343.    
  344.     Window_SimpleBeastBook_Beasts.prototype.maxCols = function() {
  345.         return 1;
  346.     };
  347.  
  348.     Window_SimpleBeastBook_Beasts.prototype.maxItems = function() {
  349.         return this._list ? this._list.length : 0;
  350.     };
  351.    
  352.     Window_SimpleBeastBook_Beasts.prototype.setCat = function(cat) {
  353.         this._cat = cat;
  354.         this.refresh();
  355.     };
  356.    
  357.     Window_SimpleBeastBook_Beasts.prototype.setInfoWindows = function(window1, window2) {
  358.         this._spriteWindow = window1;
  359.         this._infoWindow = window2;
  360.         this.updateStatus();
  361.     };
  362.    
  363.     Window_SimpleBeastBook_Beasts.prototype.update = function() {
  364.         Window_Selectable.prototype.update.call(this);
  365.         this.updateStatus();
  366.     };
  367.    
  368.     Window_SimpleBeastBook_Beasts.prototype.updateStatus = function() {
  369.         var beast = this._list[this.index()];
  370.         if (this._spriteWindow) this._spriteWindow.setBeast(beast);
  371.         if (this._infoWindow) this._infoWindow.setBeast(beast);
  372.     };
  373.  
  374.     Window_SimpleBeastBook_Beasts.prototype.refresh = function() {
  375.         this._list = [];
  376.         for (var i = 1; i < $simpleBeastBook.beasts[1].length; i++) {
  377.             var beast = $simpleBeastBook.beasts[1][i];
  378.             if (beast.cat == this._cat) this._list.push(beast);
  379.         }
  380.         this.createContents();
  381.         this.drawAllItems();
  382.     };
  383.  
  384.     Window_SimpleBeastBook_Beasts.prototype.drawItem = function(index) {
  385.         var beast = this._list[index],
  386.             rect = this.itemRectForText(index),
  387.             id = "",
  388.             name = beast.name;
  389.            
  390.         if (stv_SimpleBeastBook_showId == "TRUE") id = '%1'.format((beast.id).padZero(3)) + " - ";
  391.            
  392.         if (!beast.discovered) {
  393.             this.changeTextColor(this.textColor(7));
  394.             name = stv_SimpleBeastBook_unknown;
  395.         }
  396.        
  397.         this.drawText(id + name, rect.x, rect.y, rect.width);
  398.         this.changeTextColor(this.normalColor());
  399.     };
  400.    
  401.     Window_SimpleBeastBook_Beasts.prototype.processOk = function() {
  402.         var beast = this._list[this._index];
  403.         console.log(beast);
  404.         if (!beast.discovered) {
  405.             this.playBuzzerSound();
  406.         } else {
  407.             Window_Selectable.prototype.processOk.call(this);
  408.         }
  409.     };
  410.    
  411. // ----------------------------------------------------------------------------------------------------------------------------
  412. // Fill Sprite Window
  413. // ----------------------------------------------------------------------------------------------------------------------------
  414.     function Window_SimpleBeastBook_Sprite() {
  415.         this.initialize.apply(this, arguments);
  416.     }
  417.  
  418.     Window_SimpleBeastBook_Sprite.prototype = Object.create(Window_Base.prototype);
  419.     Window_SimpleBeastBook_Sprite.prototype.constructor = Window_SimpleBeastBook_Sprite;
  420.  
  421.     Window_SimpleBeastBook_Sprite.prototype.initialize = function(x, y, width, height) {
  422.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  423.         this.setBeastSprite();
  424.     };
  425.    
  426.     Window_SimpleBeastBook_Sprite.prototype.setBeast = function(beast) {
  427.         this._beast = beast;
  428.         this.refresh();
  429.     };
  430.    
  431.     Window_SimpleBeastBook_Sprite.prototype.setBeastSprite = function() {
  432.         this._beastSprite = new Sprite();
  433.         this._beastSprite.anchor.x = 0.5;
  434.         this._beastSprite.anchor.y = 0.5;
  435.         this._beastSprite.x = this.width/2;
  436.         this._beastSprite.y = this.height/2;
  437.         this._beastSprite.scale.x = 0.8;
  438.         this._beastSprite.scale.y = 0.8;
  439.         this.addChildToBack(this._beastSprite);
  440.     };
  441.    
  442.     Window_SimpleBeastBook_Sprite.prototype.deleteBitmap = function() {
  443.         this._beastSprite.bitmap = null;
  444.     };
  445.    
  446.     Window_SimpleBeastBook_Sprite.prototype.drawBeastStatic = function() {
  447.         this._beastSprite.bitmap = ImageManager.loadEnemy(this._beast.pic, 0);
  448.     };
  449.    
  450.     Window_SimpleBeastBook_Sprite.prototype.drawDiscovered = function() {
  451.         this.drawBeastStatic();
  452.     };
  453.    
  454.     Window_SimpleBeastBook_Sprite.prototype.refresh = function() {
  455.         this.contents.clear();
  456.         this.deleteBitmap();
  457.         if (this._beast.discovered) this.drawDiscovered();
  458.     };
  459.    
  460. // ----------------------------------------------------------------------------------------------------------------------------
  461. // Fill Info Window
  462. // ----------------------------------------------------------------------------------------------------------------------------
  463.     function Window_SimpleBeastBook_Info() {
  464.         this.initialize.apply(this, arguments);
  465.     }
  466.  
  467.     Window_SimpleBeastBook_Info.prototype = Object.create(Window_Base.prototype);
  468.     Window_SimpleBeastBook_Info.prototype.constructor = Window_SimpleBeastBook_Info;
  469.  
  470.     Window_SimpleBeastBook_Info.prototype.initialize = function(x, y, width, height) {
  471.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  472.     };
  473.    
  474.     Window_SimpleBeastBook_Info.prototype.standardFontSize = function() {
  475.         return stv_SimpleBeastBook_fontSizeInfo;
  476.     };
  477.    
  478.     Window_SimpleBeastBook_Info.prototype.setBeast = function(beast) {
  479.         this._beast = beast;
  480.         this.refresh();
  481.     };
  482.    
  483.     Window_SimpleBeastBook_Info.prototype.drawDiscovered = function() {
  484.         //this.drawTextEx(stv_SimpleBeastBook_descText, 0, 0);
  485.         this.drawTextEx(this._beast.desc, 8, 0);
  486.     };
  487.    
  488.     Window_SimpleBeastBook_Info.prototype.refresh = function() {
  489.         this.contents.clear();
  490.         if (this._beast.discovered) this.drawDiscovered();
  491.     };
  492.  
  493. // ----------------------------------------------------------------------------------------------------------------------------
  494. // Alias methods
  495. // ----------------------------------------------------------------------------------------------------------------------------
  496.     STV_SimpleBeastBook_PluginCommand = Game_Interpreter.prototype.pluginCommand;
  497.     STV_SimpleBeastBook_Create = DataManager.createGameObjects;
  498.     STV_SimpleBeastBook_Save = DataManager.makeSaveContents;
  499.     STV_SimpleBeastBook_Load = DataManager.extractSaveContents;
  500.     STV_SimpleBeastBook_BattleBack = Spriteset_Battle.prototype.createBattleback;
  501.     STV_SimpleBeastBook_DropItems = Game_Enemy.prototype.makeDropItems;
  502.  
  503. // ----------------------------------------------------------------------------------------------------------------------------
  504. // DataManager
  505. // ----------------------------------------------------------------------------------------------------------------------------
  506.     var $simpleBeastBook = null;
  507.  
  508.     DataManager.makeSaveContents = function() {
  509.         contents = STV_SimpleBeastBook_Save.call(this);
  510.         contents.simplebeastbook = $simpleBeastBook;
  511.         return contents;
  512.     };
  513.    
  514.     DataManager.extractSaveContents = function(contents) {
  515.         STV_SimpleBeastBook_Load.call(this, contents);
  516.         $simpleBeastBook = contents.simplebeastbook;
  517.     };
  518.    
  519.     DataManager.createGameObjects = function() {
  520.         STV_SimpleBeastBook_Create.call(this);
  521.         $simpleBeastBook = new SimpleBeast_Book();
  522.     };
  523.    
  524. // ----------------------------------------------------------------------------------------------------------------------------
  525. // Get EnemyTroop Info
  526. // ----------------------------------------------------------------------------------------------------------------------------
  527.     Game_Troop.prototype.updateInterpreter = function() {
  528.         this._interpreter.update();
  529.  
  530.             for (var i = 0; i < $gameTroop.members().length; i++) {
  531.             var stv_beastID = $gameTroop.members()[i]._enemyId;
  532.             var stv_beastIsAlive = $gameTroop.members()[i].isAlive();
  533.            
  534.             switch (stv_SimpleBeastBook_fillBehavior) {
  535.                 case 1:
  536.                     $simpleBeastBook.discoverBeast(stv_beastID);
  537.                 break;
  538.                 case 2:
  539.                     if (!stv_beastIsAlive){
  540.                         $simpleBeastBook.discoverBeast(stv_beastID);
  541.                     }
  542.                 break;
  543.                 case 3:
  544.                 break;
  545.             }
  546.         }
  547.     };
  548.  
  549. // ----------------------------------------------------------------------------------------------------------------------------
  550. // SimpleBeast_Book
  551. // ----------------------------------------------------------------------------------------------------------------------------
  552.  
  553.     function SimpleBeast_Book() {
  554.         this.initialize.apply(this, arguments);
  555.     }
  556.    
  557.     SimpleBeast_Book.prototype.initialize = function() {
  558.         this.setup();
  559.         console.log(this.beasts);
  560.     };
  561.    
  562.     // Setup Book
  563.     SimpleBeast_Book.prototype.setup = function() {
  564.         this.beasts = [];
  565.         this.clear();
  566.     };
  567.    
  568.     // Clear Book
  569.     SimpleBeast_Book.prototype.clear= function() {
  570.         this.createCats();
  571.         this.createBeasts();
  572.     };
  573.    
  574.     // Create Cats
  575.     SimpleBeast_Book.prototype.createCats = function() {
  576.         this.beasts[0] = [];
  577.         for (var i = 1; i < $dataEnemies.length; ++i) {
  578.             var note = $dataEnemies[i].note,
  579.                 cat;
  580.  
  581.             if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) {
  582.                 cat = String(RegExp.$1);
  583.                 if (this.beasts[0].indexOf(cat) == -1) this.beasts[0].push(cat);
  584.             }
  585.         }
  586.     };
  587.    
  588.     // Create Beasts
  589.     SimpleBeast_Book.prototype.createBeasts = function() {
  590.         this.beasts[1] = [];
  591.         for (var i = 1; i < $dataEnemies.length; ++i) {
  592.             var note = $dataEnemies[i].note,
  593.                 cat = "",
  594.                 desc = "",
  595.                 pic = $dataEnemies[i].battlerName;
  596.            
  597.             if (note.match(/<STVSBB Desc>((.|\n)*?)<\/STVSBB Desc>/g)) desc = String(RegExp.$1);
  598.             if (note.match(/<(?:STVSBB PIC):[ ](.*)>/i)) pic = String(RegExp.$1);
  599.             if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) {
  600.                 cat = String(RegExp.$1);
  601.                 var object = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false};
  602.                 this.beasts[1][i] = object;
  603.             }
  604.         }
  605.     };
  606.    
  607.     // Discover Beast
  608.     SimpleBeast_Book.prototype.discoverBeast = function(id) {
  609.         if (this.beasts[1][id]) this.beasts[1][id].discovered = true;
  610.     };
  611.    
  612.     // Discover All
  613.     SimpleBeast_Book.prototype.discoverAll = function() {
  614.         for (var i = 1; i < this.beasts[1].length; ++i) {
  615.             this.discoverBeast(i);
  616.         }
  617.     };
  618.  
  619. // ----------------------------------------------------------------------------------------------------------------------------
  620. // Plugin Commands
  621. // ----------------------------------------------------------------------------------------------------------------------------
  622.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  623.         STV_SimpleBeastBook_PluginCommand.call(this, command, args);
  624.        
  625.         if (command === 'SimpleBeastBook') {
  626.             switch (args[0]) {
  627.                 case 'open':
  628.                     SceneManager.push(Scene_SimpleBeastBook);
  629.                 break;
  630.                 case 'discover':
  631.                     $simpleBeastBook.discoverBeast(args[1]);
  632.                 break;
  633.             }
  634.         }
  635.     };
RAW Paste Data