Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // STV_SimpleBeastBook.js
- //=============================================================================
- /*:
- * @plugindesc v1.1 - STV_SimpleBeastBook
- * || This will add a Simple Beast Register to your Game.
- * @author SkottyTV
- *
- * @param --- Functions ---
- *
- * @param Fill Behavior
- * @desc How the Book will get filled.
- * 1 = Encounter / 2 = Kill / 3 = None (only commands)
- * @default 2
- *
- * @param Max Cat Cols
- * @desc The Maximum Categorys visible at once.
- * @default 4
- *
- * @param Show ID
- * @desc Show ID in front of a Beast.
- * (Show = TRUE / Hide = FALSE)
- * @default TRUE
- *
- * @param --- Font Size ---
- *
- * @param Font Size Cat
- * @desc Font Size of the Category Window
- * @default 24
- *
- * @param Font Size Beasts
- * @desc Font Size of the Category Window
- * @default 16
- *
- * @param Font Size Info
- * @desc Font Size of the Category Window
- * @default 16
- *
- * @param ----- Text -----
- *
- * @param Unknown Text
- * @desc The default Text for unknown data.
- * @default ?????
- *
- * @param Description Text
- * @desc The default Text for "Description:"
- * (NO FUNCTION!)
- * @default Description:
- *
- *
- * @help
- *
- * ////////////////////////////////////////////////////////////////////////////
- * ----------------------------- Terms of Usage: ------------------------------
- * ////////////////////////////////////////////////////////////////////////////
- * Feel free to use this Plugin in 1. Non-Commercial Games, 2. Commercial Games
- * However it would be nice to give proper Credits to "SkottyTV"
- * Also a free copy of your Game would be a nice move :)
- *
- * Have Fun And Enjoy! :)
- *
- *
- *
- * ////////////////////////////////////////////////////////////////////////////
- * --------------------------------- Updates:----------------------------------
- * ////////////////////////////////////////////////////////////////////////////
- *
- * Update v1.0
- * - Basic Functionality.
- *
- * Update v1.1
- * - Added Font Size customization.
- * - Changed Window Positions.
- *
- * ////////////////////////////////////////////////////////////////////////////
- * -------------------------------- Commands: ---------------------------------
- * ////////////////////////////////////////////////////////////////////////////
- *
- * Plugin Command:
- * SimpleBeastBook open # Open the beast book screen.
- * SimpleBeastBook discover 3 # Discover enemy #3 in the beast book.
- *
- * Enemy Note:
- * <desc1:The mighty Clown> # Description text in the Beast Book, line 1
- * <STVSBB Cat: Normal> # Creates the Category "Normal" and determine
- * this Beast to it.
- * <STVSBB Pic: Normal> # Name of the default Picture for the Beast.
- * Picture has to be under "img/enemies".
- * Without this line the default picture is used.
- * <STVSBB Desc> # Start of the Beast Description.
- * This is a Bat. # Simple Text Description.
- * It has \i[5]Wings. # Description Line with Icon.
- * It sucks \c[2]Blood. # Description Line with colored Text.
- * </STVSBB Desc> # End of the Beast Description.
- *
- */
- // ----------------------------------------------------------------------------------------------------------------------------
- // STV_BeastBook Parameters
- // ----------------------------------------------------------------------------------------------------------------------------
- var stv_SimpleBeastBook_parameters = PluginManager.parameters('STV_SimpleBeastBook');
- //--- Functions ---
- var stv_SimpleBeastBook_fillBehavior = Number(stv_SimpleBeastBook_parameters['Fill Behavior'] || 2);
- var stv_SimpleBeastBook_maxCols = Number(stv_SimpleBeastBook_parameters['Max Cat Cols'] || 4);
- var stv_SimpleBeastBook_showId = String(stv_SimpleBeastBook_parameters['Show ID'] || "TRUE");
- //--- Font Size ---
- var stv_SimpleBeastBook_fontSizeCat = Number(stv_SimpleBeastBook_parameters['Font Size Cat'] || 24);
- var stv_SimpleBeastBook_fontSizeBeasts = Number(stv_SimpleBeastBook_parameters['Font Size Beasts'] || 16);
- var stv_SimpleBeastBook_fontSizeInfo = Number(stv_SimpleBeastBook_parameters['Font Size Info'] || 16);
- //----- Text -----
- var stv_SimpleBeastBook_unknown = String(stv_SimpleBeastBook_parameters['Unknown Text'] || "?????");
- //var stv_SimpleBeastBook_descText = String(stv_SimpleBeastBook_parameters['Description Text'] || "Description:");
- // ----------------------------------------------------------------------------------------------------------------------------
- // Scene SimpleBeastBook create
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook = function() {
- this.initialize.apply(this, arguments);
- };
- Scene_SimpleBeastBook.prototype = Object.create(Scene_MenuBase.prototype);
- Scene_SimpleBeastBook.prototype.constructor = Scene_SimpleBeastBook;
- Scene_SimpleBeastBook.prototype.initialize = function() {
- Scene_MenuBase.prototype.initialize.call(this);
- this._switch = false;
- };
- Scene_SimpleBeastBook.prototype.create = function() {
- Scene_MenuBase.prototype.create.call(this);
- this.createWindowPositions();
- this.createCatWindow();
- this.createBeastsWindow();
- this.createSpriteWindow();
- this.createInfoWindow();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Create Window Positions
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.createWindowPositions = function() {
- var maxWidth = Graphics.boxWidth,
- maxHeight = Graphics.boxHeight;
- var cX = 0,
- cY = 0,
- cW = maxWidth,
- cH = 72;
- this._catWindow = new Window_SimpleBeastBook_Category(cX, cY, cW, cH);
- var bX = cX,
- bY = cH,
- bW = (maxWidth/3),
- bH = maxHeight - cH;
- this._beastsWindow = new Window_SimpleBeastBook_Beasts(bX, bY, bW, bH);
- var sX = bW,
- sY = bY,
- sW = maxWidth - bW,
- sH = bH / 2;
- this._spriteWindow = new Window_SimpleBeastBook_Sprite(sX, sY, sW, sH);
- var iX = sX,
- iY = sY + sH,
- iW = sW,
- iH = sH;
- this._infoWindow = new Window_SimpleBeastBook_Info(iX, iY, iW, iH);
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Create Category Window
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.createCatWindow = function() {
- this._catWindow.setHandler('ok', this.onCatSelect.bind(this));
- this._catWindow.setHandler('cancel', this.onCatCancel.bind(this));
- this._catWindow.setBeastsWindow(this._beastsWindow);
- this.addWindow(this._catWindow);
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Create Beasts Window
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.createBeastsWindow = function() {
- this._beastsWindow.setHandler('ok', this.onBeastSelect.bind(this));
- this._beastsWindow.setHandler('cancel', this.onBeastCancel.bind(this));
- this._beastsWindow.setInfoWindows(this._spriteWindow, this._infoWindow);
- this.addWindow(this._beastsWindow);
- this._beastsWindow.hide();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Create Info Window
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.createSpriteWindow = function() {
- this.addWindow(this._spriteWindow);
- this._spriteWindow.opacity = 0;
- this._spriteWindow.hide();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Create Info Window
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.createInfoWindow = function() {
- this.addWindow(this._infoWindow);
- this._infoWindow.hide();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // On Cat Select
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.onCatSelect = function() {
- this._catWindow.deactivate();
- this._beastsWindow.show();
- this._spriteWindow.show();
- this._beastsWindow.activate();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // On Cat Cancel
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.onCatCancel = function() {
- this.popScene();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // On Beast Select
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.onBeastSelect = function() {
- if (!this._switch) {
- this._infoWindow.show();
- } else {
- this._infoWindow.hide();
- }
- this._switch = !this._switch;
- this._beastsWindow.activate();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // On Beast Cancel
- // ----------------------------------------------------------------------------------------------------------------------------
- Scene_SimpleBeastBook.prototype.onBeastCancel = function() {
- if (this._switch) {
- this._infoWindow.hide();
- this._beastsWindow.activate();
- this._switch = !this._switch;
- } else {
- this._beastsWindow.select(0);
- this._beastsWindow.deactivate();
- this._beastsWindow.hide();
- this._spriteWindow.hide();
- this._infoWindow.hide();
- this._catWindow.activate();
- }
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Fill Cat Window
- // ----------------------------------------------------------------------------------------------------------------------------
- function Window_SimpleBeastBook_Category() {
- this.initialize.apply(this, arguments);
- }
- Window_SimpleBeastBook_Category.prototype = Object.create(Window_HorzCommand.prototype);
- Window_SimpleBeastBook_Category.prototype.constructor = Window_SimpleBeastBook_Category;
- Window_SimpleBeastBook_Category.prototype.initialize = function(x, y, width, height) {
- Window_HorzCommand.prototype.initialize.call(this, x, y, width, height);
- };
- Window_SimpleBeastBook_Category.prototype.standardFontSize = function() {
- return stv_SimpleBeastBook_fontSizeCat;
- };
- Window_SimpleBeastBook_Category.prototype.maxCols = function() {
- if ($simpleBeastBook.beasts[0].length >= stv_SimpleBeastBook_maxCols) {
- return stv_SimpleBeastBook_maxCols;
- } else {
- return $simpleBeastBook.beasts[0].length;
- }
- };
- Window_SimpleBeastBook_Category.prototype.windowWidth = function() {
- return Graphics.boxWidth;
- };
- Window_SimpleBeastBook_Category.prototype.windowHeight = function() {
- return 72;
- };
- Window_SimpleBeastBook_Category.prototype.setBeastsWindow = function(window1) {
- this._beastsWindow = window1;
- this.updateStatus();
- };
- Window_SimpleBeastBook_Category.prototype.update = function() {
- Window_Selectable.prototype.update.call(this);
- this.updateStatus();
- };
- Window_SimpleBeastBook_Category.prototype.updateStatus = function() {
- var cat = this._list[this.index()].name;
- if (this._beastsWindow) this._beastsWindow.setCat(cat);
- };
- Window_SimpleBeastBook_Category.prototype.makeCommandList = function() {
- var cats = $simpleBeastBook.beasts[0];
- for (var i = 0; i < cats.length; ++i) {
- this.addCommand(cats[i], 'ok');
- }
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Fill Beasts Window
- // ----------------------------------------------------------------------------------------------------------------------------
- function Window_SimpleBeastBook_Beasts() {
- this.initialize.apply(this, arguments);
- }
- Window_SimpleBeastBook_Beasts.prototype = Object.create(Window_Selectable.prototype);
- Window_SimpleBeastBook_Beasts.prototype.constructor = Window_SimpleBeastBook_Beasts;
- Window_SimpleBeastBook_Beasts.lastTopRow = 0;
- Window_SimpleBeastBook_Beasts.lastIndex = 0;
- Window_SimpleBeastBook_Beasts.prototype.initialize = function(x, y, width, height) {
- Window_Selectable.prototype.initialize.call(this, x, y, width, height);
- this.refresh();
- this.setTopRow(Window_SimpleBeastBook_Beasts.lastTopRow);
- this.select(Window_SimpleBeastBook_Beasts.lastIndex);
- };
- Window_SimpleBeastBook_Beasts.prototype.standardFontSize = function() {
- return stv_SimpleBeastBook_fontSizeBeasts;
- };
- Window_SimpleBeastBook_Beasts.prototype.maxCols = function() {
- return 1;
- };
- Window_SimpleBeastBook_Beasts.prototype.maxItems = function() {
- return this._list ? this._list.length : 0;
- };
- Window_SimpleBeastBook_Beasts.prototype.setCat = function(cat) {
- this._cat = cat;
- this.refresh();
- };
- Window_SimpleBeastBook_Beasts.prototype.setInfoWindows = function(window1, window2) {
- this._spriteWindow = window1;
- this._infoWindow = window2;
- this.updateStatus();
- };
- Window_SimpleBeastBook_Beasts.prototype.update = function() {
- Window_Selectable.prototype.update.call(this);
- this.updateStatus();
- };
- Window_SimpleBeastBook_Beasts.prototype.updateStatus = function() {
- var beast = this._list[this.index()];
- if (this._spriteWindow) this._spriteWindow.setBeast(beast);
- if (this._infoWindow) this._infoWindow.setBeast(beast);
- };
- Window_SimpleBeastBook_Beasts.prototype.refresh = function() {
- this._list = [];
- for (var i = 1; i < $simpleBeastBook.beasts[1].length; i++) {
- var beast = $simpleBeastBook.beasts[1][i];
- if (beast.cat == this._cat) this._list.push(beast);
- }
- this.createContents();
- this.drawAllItems();
- };
- Window_SimpleBeastBook_Beasts.prototype.drawItem = function(index) {
- var beast = this._list[index],
- rect = this.itemRectForText(index),
- id = "",
- name = beast.name;
- if (stv_SimpleBeastBook_showId == "TRUE") id = '%1'.format((beast.id).padZero(3)) + " - ";
- if (!beast.discovered) {
- this.changeTextColor(this.textColor(7));
- name = stv_SimpleBeastBook_unknown;
- }
- this.drawText(id + name, rect.x, rect.y, rect.width);
- this.changeTextColor(this.normalColor());
- };
- Window_SimpleBeastBook_Beasts.prototype.processOk = function() {
- var beast = this._list[this._index];
- console.log(beast);
- if (!beast.discovered) {
- this.playBuzzerSound();
- } else {
- Window_Selectable.prototype.processOk.call(this);
- }
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Fill Sprite Window
- // ----------------------------------------------------------------------------------------------------------------------------
- function Window_SimpleBeastBook_Sprite() {
- this.initialize.apply(this, arguments);
- }
- Window_SimpleBeastBook_Sprite.prototype = Object.create(Window_Base.prototype);
- Window_SimpleBeastBook_Sprite.prototype.constructor = Window_SimpleBeastBook_Sprite;
- Window_SimpleBeastBook_Sprite.prototype.initialize = function(x, y, width, height) {
- Window_Base.prototype.initialize.call(this, x, y, width, height);
- this.setBeastSprite();
- };
- Window_SimpleBeastBook_Sprite.prototype.setBeast = function(beast) {
- this._beast = beast;
- this.refresh();
- };
- Window_SimpleBeastBook_Sprite.prototype.setBeastSprite = function() {
- this._beastSprite = new Sprite();
- this._beastSprite.anchor.x = 0.5;
- this._beastSprite.anchor.y = 0.5;
- this._beastSprite.x = this.width/2;
- this._beastSprite.y = this.height/2;
- this._beastSprite.scale.x = 0.8;
- this._beastSprite.scale.y = 0.8;
- this.addChildToBack(this._beastSprite);
- };
- Window_SimpleBeastBook_Sprite.prototype.deleteBitmap = function() {
- this._beastSprite.bitmap = null;
- };
- Window_SimpleBeastBook_Sprite.prototype.drawBeastStatic = function() {
- this._beastSprite.bitmap = ImageManager.loadEnemy(this._beast.pic, 0);
- };
- Window_SimpleBeastBook_Sprite.prototype.drawDiscovered = function() {
- this.drawBeastStatic();
- };
- Window_SimpleBeastBook_Sprite.prototype.refresh = function() {
- this.contents.clear();
- this.deleteBitmap();
- if (this._beast.discovered) this.drawDiscovered();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Fill Info Window
- // ----------------------------------------------------------------------------------------------------------------------------
- function Window_SimpleBeastBook_Info() {
- this.initialize.apply(this, arguments);
- }
- Window_SimpleBeastBook_Info.prototype = Object.create(Window_Base.prototype);
- Window_SimpleBeastBook_Info.prototype.constructor = Window_SimpleBeastBook_Info;
- Window_SimpleBeastBook_Info.prototype.initialize = function(x, y, width, height) {
- Window_Base.prototype.initialize.call(this, x, y, width, height);
- };
- Window_SimpleBeastBook_Info.prototype.standardFontSize = function() {
- return stv_SimpleBeastBook_fontSizeInfo;
- };
- Window_SimpleBeastBook_Info.prototype.setBeast = function(beast) {
- this._beast = beast;
- this.refresh();
- };
- Window_SimpleBeastBook_Info.prototype.drawDiscovered = function() {
- //this.drawTextEx(stv_SimpleBeastBook_descText, 0, 0);
- this.drawTextEx(this._beast.desc, 8, 0);
- };
- Window_SimpleBeastBook_Info.prototype.refresh = function() {
- this.contents.clear();
- if (this._beast.discovered) this.drawDiscovered();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Alias methods
- // ----------------------------------------------------------------------------------------------------------------------------
- STV_SimpleBeastBook_PluginCommand = Game_Interpreter.prototype.pluginCommand;
- STV_SimpleBeastBook_Create = DataManager.createGameObjects;
- STV_SimpleBeastBook_Save = DataManager.makeSaveContents;
- STV_SimpleBeastBook_Load = DataManager.extractSaveContents;
- STV_SimpleBeastBook_BattleBack = Spriteset_Battle.prototype.createBattleback;
- STV_SimpleBeastBook_DropItems = Game_Enemy.prototype.makeDropItems;
- // ----------------------------------------------------------------------------------------------------------------------------
- // DataManager
- // ----------------------------------------------------------------------------------------------------------------------------
- var $simpleBeastBook = null;
- DataManager.makeSaveContents = function() {
- contents = STV_SimpleBeastBook_Save.call(this);
- contents.simplebeastbook = $simpleBeastBook;
- return contents;
- };
- DataManager.extractSaveContents = function(contents) {
- STV_SimpleBeastBook_Load.call(this, contents);
- $simpleBeastBook = contents.simplebeastbook;
- };
- DataManager.createGameObjects = function() {
- STV_SimpleBeastBook_Create.call(this);
- $simpleBeastBook = new SimpleBeast_Book();
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Get EnemyTroop Info
- // ----------------------------------------------------------------------------------------------------------------------------
- Game_Troop.prototype.updateInterpreter = function() {
- this._interpreter.update();
- for (var i = 0; i < $gameTroop.members().length; i++) {
- var stv_beastID = $gameTroop.members()[i]._enemyId;
- var stv_beastIsAlive = $gameTroop.members()[i].isAlive();
- switch (stv_SimpleBeastBook_fillBehavior) {
- case 1:
- $simpleBeastBook.discoverBeast(stv_beastID);
- break;
- case 2:
- if (!stv_beastIsAlive){
- $simpleBeastBook.discoverBeast(stv_beastID);
- }
- break;
- case 3:
- break;
- }
- }
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // SimpleBeast_Book
- // ----------------------------------------------------------------------------------------------------------------------------
- function SimpleBeast_Book() {
- this.initialize.apply(this, arguments);
- }
- SimpleBeast_Book.prototype.initialize = function() {
- this.setup();
- console.log(this.beasts);
- };
- // Setup Book
- SimpleBeast_Book.prototype.setup = function() {
- this.beasts = [];
- this.clear();
- };
- // Clear Book
- SimpleBeast_Book.prototype.clear= function() {
- this.createCats();
- this.createBeasts();
- };
- // Create Cats
- SimpleBeast_Book.prototype.createCats = function() {
- this.beasts[0] = [];
- for (var i = 1; i < $dataEnemies.length; ++i) {
- var note = $dataEnemies[i].note,
- cat;
- if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) {
- cat = String(RegExp.$1);
- if (this.beasts[0].indexOf(cat) == -1) this.beasts[0].push(cat);
- }
- }
- };
- // Create Beasts
- SimpleBeast_Book.prototype.createBeasts = function() {
- this.beasts[1] = [];
- for (var i = 1; i < $dataEnemies.length; ++i) {
- var note = $dataEnemies[i].note,
- cat = "",
- desc = "",
- pic = $dataEnemies[i].battlerName;
- if (note.match(/<STVSBB Desc>((.|\n)*?)<\/STVSBB Desc>/g)) desc = String(RegExp.$1);
- if (note.match(/<(?:STVSBB PIC):[ ](.*)>/i)) pic = String(RegExp.$1);
- if (note.match(/<(?:STVSBB CAT):[ ](.*)>/i)) {
- cat = String(RegExp.$1);
- var object = {"id":$dataEnemies[i].id, "cat":cat, "name":$dataEnemies[i].name, "desc":desc, "pic":pic, "discovered":false};
- this.beasts[1][i] = object;
- }
- }
- };
- // Discover Beast
- SimpleBeast_Book.prototype.discoverBeast = function(id) {
- if (this.beasts[1][id]) this.beasts[1][id].discovered = true;
- };
- // Discover All
- SimpleBeast_Book.prototype.discoverAll = function() {
- for (var i = 1; i < this.beasts[1].length; ++i) {
- this.discoverBeast(i);
- }
- };
- // ----------------------------------------------------------------------------------------------------------------------------
- // Plugin Commands
- // ----------------------------------------------------------------------------------------------------------------------------
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- STV_SimpleBeastBook_PluginCommand.call(this, command, args);
- if (command === 'SimpleBeastBook') {
- switch (args[0]) {
- case 'open':
- SceneManager.push(Scene_SimpleBeastBook);
- break;
- case 'discover':
- $simpleBeastBook.discoverBeast(args[1]);
- break;
- }
- }
- };
RAW Paste Data