Status
Not open for further replies.

sieben43

Veteran
Veteran
Joined
Oct 25, 2015
Messages
66
Reaction score
12
First Language
German, English
Primarily Uses
RMMV
Hello everyone, maybe somebody can help me.

I've decided to add the Gacha and GachaBook plugin and created a bunch of cards already, the whole receiving the cards/items works well so far, even though the defined animation for retrieving the capsule is not being showed, the star animation to show the rarity does show up though.
Anyway, when opening the GachaBook by using the plugin command: GachaBook open, I only receive a TypeError; Cannot read property 'name' of null.
The console gives me the following:
Unbenannt_1.jpg
I have no clue what causes the window not to be created. Both plugins work without issues in a new, empty project. I'm using the most recent version of RPG Maker MV, 1.5.1 and have properly updated all relevant files and libs.
I also just can't test disabling 100+ plugins to see if any of them is causing issues.
Maybe someone has an idea what else I could check.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,334
Reaction score
15,157
First Language
English
Primarily Uses
RMMV
Usually when you ask for help with plugins, it helps us if you include a link to the plugin - thread or blog post is preferable.

Did you start a new game after adding the plugin?

I also just can't test disabling 100+ plugins to see if any of them is causing issues.

Sometimes that is exactly what you have to do. We're not there yet, but you need to be prepared to do that if your problem can't be solved any other way.
 

sieben43

Veteran
Veteran
Joined
Oct 25, 2015
Messages
66
Reaction score
12
First Language
German, English
Primarily Uses
RMMV
Uhm it's the Gacha and GachaBook plugin that got shipped with the 1.1 RPG Maker MV Update.
I thought it wasn't necessary to add this, since I believed it had been included in every update.
I can post the plugins with highlights of the relevant lines of course.

Did you start a new game after adding the plugin?

Yes I did, I also put in the Gacha clear and GachaBook clear commands before adding or readding items to make sure it gets initialized without issues. And the cards are also being shown when receiving them, they also appear in the item section with name and description.

Sometimes that is exactly what you have to do. We're not there yet, but you need to be prepared to do that if your problem can't be solved any other way.

Yeah I know, that's why I already mentioned it, but I'd like to avoid that if possible. I atleast already disable Yanfly's Core Engine and several other plugins that alter windows or the resolution.


I remembered seeing SumRndmDde doing a tutorial on Youtube back then and I watched it again to make sure I haven't missed anything during the setup. That was not the case, but someone inthe comments seemed to encounter the same issue.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,334
Reaction score
15,157
First Language
English
Primarily Uses
RMMV
Uhm it's the Gacha and GachaBook plugin that got shipped with the 1.1 RPG Maker MV Update.

The plugin name wasn't familiar to me (and might not be familiar to others), so would have been good to at least state where it came from. It would have been even harder to find if I'd searched for it, because I would have searched online.

Does this list particular items in inventory? Is there any chance you have deleted some item slots but it's still trying to list one of them? If it's trying to show a name for an item and you've deleted it from the Item tab, it could throw this error. This would also explain why it won't work in your project, but it will work in a new project.

Other things I can think of to try ...
- ensure all of your plugins (especially Yanfly's) are in the correct order.
- the error log lists Yanfly's FpsSynchOption plugin. I really doubt this would be an issue, but disable that one, save & play again and see if it makes a difference.

Other than that, I'd have to look at the plugin and see what it's trying to do in the Window_GachaBookIndex.refresh function, but I won't be able to do that until I get home later this evening.



Edit: I don't see a GachaBook plugin with any version of MV that I have installed. Maybe it was only available as a separate download with that particular update. I am trying to download it, but it keeps timing out on me, so I'm not sure I can be of any further assistance.

Edit 2: found one! That particular line is looking for a weapon name. This tells me you have probably deleted a weapon from the weapons tab or from the weapons.json file. If you can't figure it out, open the GachaBook.js file, and insert the following as a new line just after line 286:
Code:
console.log("Looking for weapon " + i);

then save and run. When the error happens, hit F8 to open the console, and the last weapon id that is listed is the one it's having trouble with.
 
Last edited:

sieben43

Veteran
Veteran
Joined
Oct 25, 2015
Messages
66
Reaction score
12
First Language
German, English
Primarily Uses
RMMV
Alright thank you. I did that but now the log of course gives me the "Looking for weapon" up to the limit of my database and always +1. I have 113 weapons in my database and it looks for 114. When I changed the database limit to 120 for example, it said it looked for weapons up to 121 and then gave me the TypeError again. I never modified the Weapons.json file and my Weapon limit in the database never decreased, only increased when I added new ones.

Another weird thing is that I never added weapons to the GachaBook, I don't even know why it wants to check for them, I only added items.

Here are the two plugins in case you were not able to download them.

//=============================================================================
// Gacha.js
//
// (c)2016 KADOKAWA CORPORATION./YOJI OJIMA
//=============================================================================

/*:
* @plugindesc Get the item at random
* @author Takeya Kimura
*
* @param Help Message Text
* @desc The help message for gacha window. "Required Amount" is replaced with the Required Amount.
* @Default 1回Required Amount\Gでガチャを引きます
*
* @param Button Text
* @desc The button text for gacha commands.
* @Default ガチャを引く
*
* @param Get Message Text
* @desc The message of After receiving. "Item Name" is replaced with the received item name.
* @Default GET Item Name
*
* @param Show Item Description
* @desc The switch of item description display
* @Default 0
*
* @param Effect
* @desc The animation number for get effect.
* @Default 119
* @require 1
* @type animation
*
* @param Rank1 Effect
* @desc The animation number for rank 1 effect. If you specify -1, does not display the animation.
* @Default -1
* @require 1
* @type animation
*
* @param Rank2 Effect
* @desc The animation number for rank 2 effect. If you specify -1, does not display the animation.
* @Default -1
* @require 1
* @type animation
*
* @param Rank3 Effect
* @desc The animation number for rank 3 effect. If you specify -1, does not display the animation.
* @Default -1
* @require 1
* @type animation
*
* @param Rank4 Effect
* @desc The animation number for rank 4 effect. If you specify -1, does not display the animation.
* @Default -1
* @require 1
* @type animation
*
* @param Rank5 Effect
* @desc The animation number for rank 5 effect. If you specify -1, does not display the animation.
* @Default -1
* @require 1
* @type animation
*
* @param ME
* @desc The ME name for get music effect.
* @Default Organ
* @require 1
* @dir audio/me/
* @type file
*
* @param Required Amount
* @desc The Gold for gacha.
* @Default 100
*
* @noteParam gachaImage
* @noteRequire 1
* @noteDir img/gacha/
* @noteType file
* @noteData items
*
* @Help
*
* Plugin Command:
* Gacha open # Open the Gacha screen
* Gacha add item 1 # Add item #1 to the Gacha
* Gacha remove item 1 # Remove item #1 from the Gacha
* Gacha clear # Clear the Gacha
*
*
* Item Note:
* <gachaImage:image> # Gacha image file name. Please image put in "img/gacha/" folder.
* <gachaNumLot:10> # The number of the lottery.
* <gachaRank:5> # The rank of the item(1-5).
*/

/*:ja
* @plugindesc ランダムにアイテムを取得します。
* @author Takeya Kimura
*
* @param Help Message Text
* @desc ガチャ画面のヘルプメッセージです。「Required Amount」は消費Gと置換されます。
* @Default 1回Required Amount\Gでガチャを引きます
*
* @param Button Text
* @desc ガチャボタンに表示するテキストです。
* @Default ガチャを引く
*
* @param Get Message Text
* @desc ガチャを引いた後のメッセージです。「Item Name」は取得アイテム名と置換されます。
* @Default GET Item Name
*
* @param Show Item Description
* @desc 1でアイテム取得時に説明を表示します。[0: 説明非表示 1: 説明表示]
* @Default 0
*
* @param Effect
* @desc アイテム取得時のアニメーションIDを指定します。
* @Default 119
* @require 1
* @type animation
*
* @param Rank1 Effect
* @desc ランク1の時のアニメーションIDを指定します。-1を指定するとアニメーションを表示しません。
* @Default -1
* @require 1
* @type animation
*
* @param Rank2 Effect
* @desc ランク2の時のアニメーションIDを指定します。-1を指定するとアニメーションを表示しません。
* @Default -1
* @require 1
* @type animation
*
* @param Rank3 Effect
* @desc ランク3の時のアニメーションIDを指定します。-1を指定するとアニメーションを表示しません。
* @Default -1
* @require 1
* @type animation
*
* @param Rank4 Effect
* @desc ランク4の時のアニメーションIDを指定します。-1を指定するとアニメーションを表示しません。
* @Default -1
* @require 1
* @type animation
*
* @param Rank5 Effect
* @desc ランク5の時のアニメーションIDを指定します。-1を指定するとアニメーションを表示しません。
* @Default -1
* @require 1
* @type animation
*
* @param ME
* @desc アイテム取得時のMEを指定します。
* @Default Organ
* @require 1
* @dir audio/me/
* @type file
*
* @param Required Amount
* @desc ガチャを引くのに必要なGです。
* @Default 100
*
* @noteParam gachaImage
* @noteRequire 1
* @noteDir img/gacha/
* @noteType file
* @noteData items
*
* @Help
*
* Plugin Command:
* Gacha open # ガチャ画面を開きます。
* Gacha add item 1 # アイテム番号1をガチャ対象に追加します。
* Gacha remove item 1 # アイテム番号1をガチャ対象から外します。
* Gacha clear # 全てのガチャ対象をクリアします。
*
*
* Item Note:
* <gachaImage:image> # ガチャアイテムの画像を指定します。画像はimg/gacha/フォルダ内に入れてください。
* <gachaNumLot:10> # ガチャアイテムのくじ数を指定します。
* <gachaRank:5> # ガチャアイテムのランクを1から5の間で指定します。
*/

(function () {

var parameters = PluginManager.parameters('Gacha');
var message = String(parameters['Help Message Text'] || '1回Required Amount\\Gでガチャを引きます');
var buttonText = String(parameters['Button Text'] || 'ガチャを引く');
var getText = String(parameters['Get Message Text'] || 'GET Item Name');
var itemDescEnable = !!Number(parameters['Show Item Description'] || 0);
var effect = Number(parameters['Effect'] || '119');
var rankEffect = [];
rankEffect.push(Number(parameters['Rank1 Effect'] || '-1'));
rankEffect.push(Number(parameters['Rank2 Effect'] || '-1'));
rankEffect.push(Number(parameters['Rank3 Effect'] || '-1'));
rankEffect.push(Number(parameters['Rank4 Effect'] || '-1'));
rankEffect.push(Number(parameters['Rank5 Effect'] || '-1'));
var me = String(parameters['ME'] || 'Organ');
var amount = Number(parameters['Required Amount'] || '100');
var reg = /Required Amount/gi;
message = message.replace(reg, String(amount));


var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === "Gacha") {
switch (args[0]) {
case "open":
SceneManager.push(Scene_Gacha);
break;

case 'add':
$gameSystem.addToGacha(args[1], Number(args[2]));
break;

case 'remove':
$gameSystem.removeFromGacha(args[1], Number(args[2]));
break;

case 'clear':
$gameSystem.clearGacha();
break;
}
}
};


Game_System.prototype.addToGacha = function(type, dataId) {
if (!this._GachaFlags) {
this.clearGacha();
}
var typeIndex = this.gachaTypeToIndex(type);
if (typeIndex >= 0) {
this._GachaFlags[typeIndex][dataId] = true;
}
};

Game_System.prototype.removeFromGacha = function(type, dataId) {
if (this._GachaFlags) {
var typeIndex = this.gachaTypeToIndex(type);
if (typeIndex >= 0) {
this._GachaFlags[typeIndex][dataId] = false;
}
}
};

Game_System.prototype.gachaTypeToIndex = function(type) {
switch (type) {
case 'item':
return 0;
case 'weapon':
return 1;
case 'armor':
return 2;
default:
return -1;
}
};

Game_System.prototype.clearGacha = function() {
this._GachaFlags = [[], [], []];
};

Game_System.prototype.isInGacha = function(item) {
if (this._GachaFlags && item) {
var typeIndex = -1;
if (DataManager.isItem(item)) {
typeIndex = 0;
} else if (DataManager.isWeapon(item)) {
typeIndex = 1;
} else if (DataManager.isArmor(item)) {
typeIndex = 2;
}
if (typeIndex >= 0) {
return !!this._GachaFlags[typeIndex][item.id];
} else {
return false;
}
} else {
return false;
}
};


function Scene_Gacha() {
this.initialize.apply(this, arguments);
}

Scene_Gacha.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Gacha.prototype.constructor = Scene_Gacha;

Scene_Gacha.prototype.initialize = function () {
Scene_MenuBase.prototype.initialize.call(this);
this._item = null;
this._effectPlaying = false;
this._resultShowing = false;
this._wait = 0;
this._effectSprite = null;
this._windowFadeSprite = null;
this._screenFadeOutDuration = 0;
this._screenFadeInDuration = 0;

this._lot = [];
var numLot;
var item, i, j;
for (i = 1; i < $dataItems.length; i++) {
item = $dataItems;
if ($gameSystem.isInGacha(item)) {
numLot = Number(item.meta.gachaNumLot || '0');
for (j = 0; j < numLot; j++) {
this._lot.push(item);
}
}
}
for (i = 1; i < $dataWeapons.length; i++) {
item = $dataWeapons;
if ($gameSystem.isInGacha(item)) {
numLot = Number(item.meta.gachaNumLot || '0');
for (j = 0; j < numLot; j++) {
this._lot.push(item);
}
}
}
for (i = 1; i < $dataArmors.length; i++) {
item = $dataArmors;
if ($gameSystem.isInGacha(item)) {
numLot = Number(item.meta.gachaNumLot || '0');
for (j = 0; j < numLot; j++) {
this._lot.push(item);
}
}
}
};

Scene_Gacha.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);

this.createHelpWindow();
this.createGoldWindow();
this.createCommandWindow();
this.createDummyWindow();
this.createGetCommandWindow();
this.createGetWindow();

this._rankSprite = new Sprite_GachaEffect();
this._rankSprite.keepDisplay(true);
this.addChild(this._rankSprite);

this._windowFadeSprite = new ScreenSprite();
this._windowFadeSprite.setColor(0, 0, 0);
this._windowFadeSprite.opacity = 0;
this._windowFadeSprite.visible = false;
this.addChild(this._windowFadeSprite);

this._effectSprite = new Sprite_GachaEffect();
this._effectSprite.x = Graphics.boxWidth / 2;
this._effectSprite.y = Graphics.boxHeight / 2;
this.addChild(this._effectSprite);

this._helpWindow.setText(message);
};

Scene_Gacha.prototype.createGoldWindow = function () {
this._goldWindow = new Window_Gold(0, this._helpWindow.height);
this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
this.addWindow(this._goldWindow);
};

Scene_Gacha.prototype.createCommandWindow = function () {
this._commandWindow = new Window_GachaCommand(this._goldWindow.x, this._purchaseOnly);
this._commandWindow.y = this._helpWindow.height;
this._commandWindow.setHandler('gacha', this.commandGacha.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this._commandWindow.lotIsValid(this._lot.length > 0);
this._commandWindow.clearCommandList();
this._commandWindow.makeCommandList();
this._commandWindow.refresh();
this.addWindow(this._commandWindow);
};

Scene_Gacha.prototype.createDummyWindow = function () {
var wy = this._commandWindow.y + this._commandWindow.height;
var wh = Graphics.boxHeight - wy;
this._dummyWindow = new Window_Base(0, wy, Graphics.boxWidth, wh);
this.addWindow(this._dummyWindow);
};

Scene_Gacha.prototype.createGetCommandWindow = function () {
this._getCommandWindow = new Window_GachaGetCommand(Graphics.boxWidth, false);
this._getCommandWindow.y = Graphics.boxHeight - this._getCommandWindow.height;
this._getCommandWindow.setHandler('cancel', this.commandOk.bind(this));
this._getCommandWindow.hide();
this.addWindow(this._getCommandWindow);
};

Scene_Gacha.prototype.createGetWindow = function () {
var wy = this._helpWindow.height;
var wh = Graphics.boxHeight - wy - this._getCommandWindow.height;
this._getWindow = new Window_GachaGet(0, wy, Graphics.boxWidth, wh);
this._getWindow.itemDescEnable(itemDescEnable);
this._getWindow.hide();
this.addWindow(this._getWindow);
};


Scene_Gacha.prototype.commandGacha = function () {
// Draw lots
if (this._lot.length <= 0) {
this._item = null;
}
else {
this._item = this._lot[(Math.random() * this._lot.length) >> 0];
$gameParty.loseGold(amount);
$gameParty.gainItem(this._item, 1);
this._goldWindow.refresh();

}

this._commandWindow.deactivate();
this._getCommandWindow.deactivate();

if (this._item) {
this._getWindow.setItem(this._item);

this._screenFadeOut();
this._effectPlaying = true;
this._wait = 0;

var animation = $dataAnimations[effect];
this._effectSprite.startAnimation(animation, false, 0);

AudioManager.playMe({"name": me, "volume": 90, "pitch": 100, "pan": 0});
}
else {
this._commandWindow.activate();
}

};

Scene_Gacha.prototype.commandOk = function () {
this._effectSprite.allRemove();
this._rankSprite.allRemove();
this._goldWindow.show();
this._commandWindow.show();
this._commandWindow.activate();
this._dummyWindow.show();
this._getCommandWindow.hide();
this._getWindow.hide();
this._helpWindow.setText(message);
this._item = null;

this._commandWindow.clearCommandList();
this._commandWindow.makeCommandList();
this._commandWindow.refresh();
};

Scene_Gacha.prototype.update = function () {
Scene_Menu.prototype.update.call(this);
this._updateScreenFlashSprite();

this._wait++;
if (this._wait > 12) {
if (this._effectPlaying) {
if (!this._effectSprite.isAnimationPlaying()) {
this._screenFadeIn();
if (!!this._item.meta.gachaImage) {
var rank = Number(this._item.meta.gachaRank || '-1');
if (rank > 0 && rank < 6) {
if (rankEffect[rank - 1] > 0) {
var animation = $dataAnimations[rankEffect[rank - 1]];
this._rankSprite.x = this._getWindow.width / 2 + this._getWindow.x - 20;
this._rankSprite.y = this._getWindow.contentsHeight() + this._getWindow.y;
if (itemDescEnable) {
this._rankSprite.y -= this._getWindow.lineHeight() * 3;
}
this._rankSprite.startAnimation(animation, false, 0);
}
}
}

this._effectPlaying = false;
this._goldWindow.hide();
this._commandWindow.hide();
this._dummyWindow.hide();
this._getCommandWindow.show();
this._getWindow.show();
var message = getText;
var reg = /Item Name/gi;
message = message.replace(reg, String(this._item.name));
this._helpWindow.setText(message);
this._wait = 0;
this._resultShowing = true;
}
else {
if (TouchInput.isTriggered() || Input.isTriggered("ok")) {
this._effectSprite.allRemove();
}
}
}
else if (this._resultShowing) {
this._resultShowing = false;
this._getCommandWindow.activate();
}
}
};

Scene_Gacha.prototype._updateScreenFlashSprite = function () {
var d;
if (this._screenFadeOutDuration > 0) {
d = this._screenFadeOutDuration--;
this._windowFadeSprite.opacity += 255 * (1 - (d - 1) / d);
}
if (this._screenFadeInDuration > 0) {
d = this._screenFadeInDuration--;
this._windowFadeSprite.opacity *= (d - 1) / d;
this._windowFadeSprite.visible = (this._screenFadeInDuration > 0);
}
};

Scene_Gacha.prototype._screenFadeOut = function() {
this._windowFadeSprite.visible = true;
this._screenFadeOutDuration = 15;
this._screenFadeInDuration = 0;
};

Scene_Gacha.prototype._screenFadeIn = function() {
this._windowFadeSprite.visible = true;
this._screenFadeOutDuration = 0;
this._screenFadeInDuration = 15;
};


function Window_Gacha() {
this.initialize.apply(this, arguments);
}

Window_Gacha.prototype = Object.create(Window_Selectable.prototype);
Window_Gacha.prototype.constructor = Window_Gacha;

Window_Gacha.prototype.initialize = function (x, y) {
var width = Graphics.boxWidth;
var height = this.fittingHeight(6);
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.refresh();
this.activate();
};


function Window_GachaCommand() {
this.initialize.apply(this, arguments);
}

Window_GachaCommand.prototype = Object.create(Window_HorzCommand.prototype);
Window_GachaCommand.prototype.constructor = Window_GachaCommand;

Window_GachaCommand.prototype.initialize = function (width, purchaseOnly) {
this._windowWidth = width;
this._purchaseOnly = purchaseOnly;
Window_HorzCommand.prototype.initialize.call(this, 0, 0);
};

Window_GachaCommand.prototype.windowWidth = function () {
return this._windowWidth;
};

Window_GachaCommand.prototype.maxCols = function () {
return 2;
};

Window_GachaCommand.prototype.makeCommandList = function () {
this.addCommand(buttonText, 'gacha', $gameParty.gold() >= amount && !!this._lotIsValid);
this.addCommand(TextManager.cancel, 'cancel');
};

Window_GachaCommand.prototype.lotIsValid = function(value) {
this._lotIsValid = value;
};


function Window_GachaGetCommand() {
this.initialize.apply(this, arguments);
}

Window_GachaGetCommand.prototype = Object.create(Window_HorzCommand.prototype);
Window_GachaGetCommand.prototype.constructor = Window_GachaGetCommand;

Window_GachaGetCommand.prototype.initialize = function (width, purchaseOnly) {
this._windowWidth = width;
this._purchaseOnly = purchaseOnly;
Window_HorzCommand.prototype.initialize.call(this, 0, 0);
};

Window_GachaGetCommand.prototype.windowWidth = function () {
return this._windowWidth;
};

Window_GachaGetCommand.prototype.maxCols = function () {
return 1;
};

Window_GachaGetCommand.prototype.makeCommandList = function () {
this.addCommand('OK', 'cancel');
};


function Window_GachaGet() {
this.initialize.apply(this, arguments);
}

Window_GachaGet.prototype = Object.create(Window_Base.prototype);
Window_GachaGet.prototype.constructor = Window_GachaGet;

Window_GachaGet.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._item = null;
this._itemDescEnable = true;
this._gachaSprite = new Sprite();
this._gachaSprite.anchor.x = 0.5;
this._gachaSprite.anchor.y = 0;
this._gachaSprite.x = width / 2 - 20;
this._gachaSprite.y = this.padding;
this.addChildToBack(this._gachaSprite);
this.refresh();
};

Window_GachaGet.prototype.itemDescEnable = function(value) {
if (this._itemDescEnable !== value) {
this._itemDescEnable = value;
this.refresh();
}
};

Window_GachaGet.prototype.setItem = function(item) {
if (this._item !== item) {
this._item = item;
this.refresh();
}
};

Window_GachaGet.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (this._gachaSprite.bitmap) {
var bitmapHeight = this._gachaSprite.bitmap.height;
var contentsHeight = this.contents.height;
if (this._itemDescEnable) {
contentsHeight -= this.lineHeight() * 3
}
var scale = 1;
if (bitmapHeight > contentsHeight) {
scale = contentsHeight / bitmapHeight;
}
this._gachaSprite.scale.x = scale;
this._gachaSprite.scale.y = scale;
}
};

Window_GachaGet.prototype.refresh = function() {
var item = this._item;
this.contents.clear();

if (this._itemDescEnable) {
var y = this.contentsHeight() - this.lineHeight() * 3;
this.drawHorzLine(y);
this.drawDescription(0, y + this.lineHeight());
}

if (!item || !item.meta.gachaImage) {
this._gachaSprite.bitmap = null;
return;
}
else {
var bitmap;
bitmap = ImageManager.loadBitmap("img/gacha/", this._item.meta.gachaImage);
this._gachaSprite.bitmap = bitmap;
bitmap.smooth = true;
}
};

Window_GachaGet.prototype.drawDescription = function(x, y) {
if (this._item) this.drawTextEx(this._item.description, x, y);
};

Window_GachaGet.prototype.drawHorzLine = function(y) {
var lineY = y + this.lineHeight() / 2 - 1;
this.contents.paintOpacity = 48;
this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.lineColor());
this.contents.paintOpacity = 255;
};

Window_GachaGet.prototype.lineColor = function() {
return this.normalColor();
};



function Sprite_GachaEffect() {
this.initialize.apply(this, arguments);
}

Sprite_GachaEffect.prototype = Object.create(Sprite.prototype);
Sprite_GachaEffect.prototype.constructor = Sprite_GachaEffect;

Sprite_GachaEffect.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this._animationSprites = [];
this._endSprites = [];
this._effectTarget = this;
this._hiding = false;
this._keepDisplay = false;
};

Sprite_GachaEffect.prototype.keepDisplay = function(value) {
this._keepDisplay = value;
};

Sprite_GachaEffect.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateVisibility();
this.updateAnimationSprites();
};

Sprite_GachaEffect.prototype.hide = function() {
this._hiding = true;
this.updateVisibility();
};

Sprite_GachaEffect.prototype.show = function() {
this._hiding = false;
this.updateVisibility();
};

Sprite_GachaEffect.prototype.updateVisibility = function() {
this.visible = !this._hiding;
};

Sprite_GachaEffect.prototype.updateAnimationSprites = function() {
if (this._animationSprites.length > 0) {
var sprites = this._animationSprites.clone();
this._animationSprites = [];
for (var i = 0; i < sprites.length; i++) {
var sprite = sprites;
if (sprite.isPlaying()) {
this._animationSprites.push(sprite);
} else {
if (!this._keepDisplay) {
sprite.remove();
}
else {
this._endSprites.push(sprite);
}
}
}
}
};

Sprite_GachaEffect.prototype.startAnimation = function(animation, mirror, delay) {
var sprite = new Sprite_Animation();
sprite.setup(this._effectTarget, animation, mirror, delay);
this.parent.addChild(sprite);
this._animationSprites.push(sprite);
};

Sprite_GachaEffect.prototype.isAnimationPlaying = function() {
return this._animationSprites.length > 0;
};

Sprite_GachaEffect.prototype.allRemove = function() {
var sprites, sprite, i;
if (this._animationSprites.length > 0) {
sprites = this._animationSprites.clone();
this._animationSprites = [];
for (i = 0; i < sprites.length; i++) {
sprite = sprites;
sprite.remove();
}
}
if (this._endSprites.length > 0) {
sprites = this._endSprites.clone();
this._endSprites = [];
for (i = 0; i < sprites.length; i++) {
sprite = sprites;
sprite.remove();
}
}
};

})();


//=============================================================================
// GachaBook.js
//
// (c)2016 KADOKAWA CORPORATION./YOJI OJIMA
//=============================================================================

/*:
* @plugindesc Displays detailed statuses of "gacha" items.
* @author Takeya Kimura
*
* @param Unknown Data
* @desc The index name for an unknown item.
* @Default ??????
*
* @param Price Text
* @desc The text for "Price".
* @Default Price
*
* @param Equip Text
* @desc The text for "Equip".
* @Default Equip
*
* @param Type Text
* @desc The text for "Type".
* @Default Type
*
* @param Rank Text
* @desc The text for "Rank".
* @Default Rank
*
* @param Simple Display
* @desc The switch to display the name and description only.
* @Default 0
*
* @Help
*
* Plugin Command:
* GachaBook open # Open the gacha book screen
* GachaBook add weapon 3 # Add weapon #3 to the gacha book
* GachaBook add armor 4 # Add armor #4 to the gacha book
* GachaBook remove armor 5 # Remove armor #5 from the gacha book
* GachaBook remove item 6 # Remove item #6 from the gacha book
* GachaBook clear # Clear the item book
*/

/*:ja
* @plugindesc ガチャアイテム一覧を表示します。
* @author Takeya Kimura
*
* @param Unknown Data
* @desc 未確認のガチャアイテムの名前です。
* @Default ??????
*
* @param Price Text
* @desc 「価格」の文字列です。
* @Default Price
*
* @param Equip Text
* @desc 「装備」の文字列です。
* @Default Equip
*
* @param Type Text
* @desc 「タイプ」の文字列です。
* @Default Type
*
* @param Rank Text
* @desc 「ランク」の文字列です。
* @Default Rank
*
* @param Simple Display
* @desc 1と入力すると詳細表示が名前と説明だけになります。[0: 通常表示 1: シンプル表示]
* @Default 0
*
* @Help
*
* Plugin Command:
* GachaBook open # ガチャブックを開きます
* GachaBook add weapon 3 # 武器3番をガチャブックに追加
* GachaBook add armor 4 # 防具4番をガチャブックに追加
* GachaBook remove armor 5 # 防具5番をガチャブックから削除
* GachaBook remove item 6 # アイテム6番をガチャブックから削除
* GachaBook clear # ガチャブックをクリアする
*/

(function() {

var parameters = PluginManager.parameters('GachaBook');
var unknownData = String(parameters['Unknown Data'] || '??????');
var priceText = String(parameters['Price Text'] || 'Price');
var equipText = String(parameters['Equip Text'] || 'Equip');
var typeText = String(parameters['Type Text'] || 'Type');
var rankText = String(parameters['Rank Text'] || 'Rank');
var simpleDisplay = !!Number(parameters['Simple Display'] || 0);

var _Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'GachaBook') {
switch (args[0]) {
case 'open':
SceneManager.push(Scene_GachaBook);
break;
case 'add':
$gameSystem.addToGachaBook(args[1], Number(args[2]));
break;
case 'remove':
$gameSystem.removeFromGachaBook(args[1], Number(args[2]));
break;
case 'complete':
$gameSystem.completeGachaBook();
break;
case 'clear':
$gameSystem.clearGachaBook();
break;
}
}
};

Game_System.prototype.addToGachaBook = function(type, dataId) {
if (!this._GachaBookFlags) {
this.clearGachaBook();
}
var typeIndex = this.gachaBookTypeToIndex(type);
if (typeIndex >= 0) {
this._GachaBookFlags[typeIndex][dataId] = true;
}
};

Game_System.prototype.removeFromGachaBook = function(type, dataId) {
if (this._GachaBookFlags) {
var typeIndex = this.gachaBookTypeToIndex(type);
if (typeIndex >= 0) {
this._GachaBookFlags[typeIndex][dataId] = false;
}
}
};

Game_System.prototype.gachaBookTypeToIndex = function(type) {
switch (type) {
case 'item':
return 0;
case 'weapon':
return 1;
case 'armor':
return 2;
default:
return -1;
}
};

Game_System.prototype.completeGachaBook = function() {
var i;
this.clearGachaBook();
for (i = 1; i < $dataItems.length; i++) {
this._GachaBookFlags[0] = true;
}
for (i = 1; i < $dataWeapons.length; i++) {
this._GachaBookFlags[1] = true;
}
for (i = 1; i < $dataArmors.length; i++) {
this._GachaBookFlags[2] = true;
}
};

Game_System.prototype.clearGachaBook = function() {
this._GachaBookFlags = [[], [], []];
};

Game_System.prototype.isInGachaBook = function(item) {
if (this._GachaBookFlags && item) {
var typeIndex = -1;
if (DataManager.isItem(item)) {
typeIndex = 0;
} else if (DataManager.isWeapon(item)) {
typeIndex = 1;
} else if (DataManager.isArmor(item)) {
typeIndex = 2;
}
if (typeIndex >= 0) {
return !!this._GachaBookFlags[typeIndex][item.id];
} else {
return false;
}
} else {
return false;
}
};

var _Game_Party_gainItem = Game_Party.prototype.gainItem;
Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
_Game_Party_gainItem.call(this, item, amount, includeEquip);
if (item && amount > 0) {
var type;
if (DataManager.isItem(item)) {
type = 'item';
} else if (DataManager.isWeapon(item)) {
type = 'weapon';
} else if (DataManager.isArmor(item)) {
type = 'armor';
}
$gameSystem.addToGachaBook(type, item.id);
}
};


function Scene_GachaBook() {
this.initialize.apply(this, arguments);
}

Scene_GachaBook.prototype = Object.create(Scene_MenuBase.prototype);
Scene_GachaBook.prototype.constructor = Scene_GachaBook;

Scene_GachaBook.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};

Scene_GachaBook.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this._indexWindow = new Window_GachaBookIndex(0, 0);
this._indexWindow.setHandler('cancel', this.popScene.bind(this));
var wy = this._indexWindow.height;
var ww = Graphics.boxWidth;
var wh = Graphics.boxHeight - wy;
this._statusWindow = new Window_GachaBookStatus(0, wy, ww, wh);
this.addWindow(this._indexWindow);
this.addWindow(this._statusWindow);
this._indexWindow.setStatusWindow(this._statusWindow);
};

function Window_GachaBookIndex() {
this.initialize.apply(this, arguments);
}

Window_GachaBookIndex.prototype = Object.create(Window_Selectable.prototype);
Window_GachaBookIndex.prototype.constructor = Window_GachaBookIndex;

Window_GachaBookIndex.lastTopRow = 0;
Window_GachaBookIndex.lastIndex = 0;

Window_GachaBookIndex.prototype.initialize = function(x, y) {
var width = Graphics.boxWidth;
var height = this.fittingHeight(6);
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.refresh();
this.setTopRow(Window_GachaBookIndex.lastTopRow);
this.select(Window_GachaBookIndex.lastIndex);
this.activate();
};

Window_GachaBookIndex.prototype.maxCols = function() {
return 3;
};

Window_GachaBookIndex.prototype.maxItems = function() {
return this._list ? this._list.length : 0;
};

Window_GachaBookIndex.prototype.setStatusWindow = function(statusWindow) {
this._statusWindow = statusWindow;
this.updateStatus();
};

Window_GachaBookIndex.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
this.updateStatus();
};

Window_GachaBookIndex.prototype.updateStatus = function() {
if (this._statusWindow) {
var item = this._list[this.index()];
this._statusWindow.setItem(item);
}
};

Window_GachaBookIndex.prototype.refresh = function() {
var i, item;
this._list = [];
for (i = 1; i < $dataItems.length; i++) {
item = $dataItems;
//if (item.name && item.itypeId === 1 && $gameSystem.isInGacha(item)) { //itypeIdはみない
if (item.name && $gameSystem.isInGacha(item)) { //itypeIdはみない
this._list.push(item);
}
}
for (i = 1; i < $dataWeapons.length; i++) {
console.log("Looking for weapon " + i);
item = $dataWeapons;
if (item.name && $gameSystem.isInGacha(item)) {
this._list.push(item);
}
}
for (i = 1; i < $dataArmors.length; i++) {
item = $dataArmors;
if (item.name && $gameSystem.isInGacha(item)) {
this._list.push(item);
}
}
this.createContents();
this.drawAllItems();
};

Window_GachaBookIndex.prototype.drawItem = function(index) {
var item = this._list[index];
var rect = this.itemRect(index);
var width = rect.width - this.textPadding();
if ($gameSystem.isInGachaBook(item)) {
this.drawItemName(item, rect.x, rect.y, width);
} else {
var iw = Window_Base._iconWidth + 4;
this.drawText(unknownData, rect.x + iw, rect.y, width - iw);
}
};

Window_GachaBookIndex.prototype.processCancel = function() {
Window_Selectable.prototype.processCancel.call(this);
Window_GachaBookIndex.lastTopRow = this.topRow();
Window_GachaBookIndex.lastIndex = this.index();
};

function Window_GachaBookStatus() {
this.initialize.apply(this, arguments);
}

Window_GachaBookStatus.prototype = Object.create(Window_Base.prototype);
Window_GachaBookStatus.prototype.constructor = Window_GachaBookStatus;

Window_GachaBookStatus.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._itemSprite = new Sprite();
this._itemSprite.anchor.x = 0.5;
this._itemSprite.anchor.y = 0.5;
this._itemSprite.x = width / 2 - 20;
this._itemSprite.y = height / 2;
this.addChildToBack(this._itemSprite);
this.refresh();
};

Window_GachaBookStatus.prototype.setItem = function(item) {
if (this._item !== item) {
this._item = item;
this.refresh();
}
};

Window_GachaBookStatus.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (this._itemSprite.bitmap) {
var bitmapHeight = this._itemSprite.bitmap.height;
var contentsHeight = this.contents.height;
var scale = 1;
if (bitmapHeight > contentsHeight) {
scale = contentsHeight / bitmapHeight;
}
this._itemSprite.scale.x = scale;
this._itemSprite.scale.y = scale;
}
};

Window_GachaBookStatus.prototype.refresh = function() {
var item = this._item;
var x = 0;
var y = 0;
var lineHeight = this.lineHeight();

this.contents.clear();

if (!item || !$gameSystem.isInGachaBook(item)) {
this._itemSprite.bitmap = null;
return;
}

var bitmap;
if (!!item.meta.gachaImage) {
bitmap = ImageManager.loadBitmap("img/gacha/", item.meta.gachaImage);
bitmap.smooth = true;
}
this._itemSprite.bitmap = bitmap;

var iconBoxWidth = Window_Base._iconWidth + 4;
this.drawItemName(item, x, y);
this.drawItemNumber(item, x + this.textWidth(item.name) + iconBoxWidth, y);

x = this.textPadding();
y = lineHeight + this.textPadding();

if (!simpleDisplay) {
var rank = "-";
if (item.meta.gachaRank) rank = item.meta.gachaRank;
this.changeTextColor(this.systemColor());
this.drawText(rankText, x, y, 120);
this.resetTextColor();
this.drawText(rank, x + 120, y, 120, 'right');
y += lineHeight;

var price = item.price > 0 ? item.price : '-';
this.changeTextColor(this.systemColor());
this.drawText(priceText, x, y, 120);
this.resetTextColor();
this.drawText(price, x + 120, y, 120, 'right');
y += lineHeight;

if (DataManager.isWeapon(item) || DataManager.isArmor(item)) {
var etype = $dataSystem.equipTypes[item.etypeId];
this.changeTextColor(this.systemColor());
this.drawText(equipText, x, y, 120);
this.resetTextColor();
this.drawText(etype, x + 120, y, 120, 'right');
y += lineHeight;

var type;
if (DataManager.isWeapon(item)) {
type = $dataSystem.weaponTypes[item.wtypeId];
} else {
type = $dataSystem.armorTypes[item.atypeId];
}
this.changeTextColor(this.systemColor());
this.drawText(typeText, x, y, 120);
this.resetTextColor();
this.drawText(type, x + 120, y, 120, 'right');

//x = this.textPadding() + 300;
//y = lineHeight + this.textPadding();
var rewardsWidth = 220;
x = this.contents.width - rewardsWidth;
y = lineHeight + this.textPadding();
for (var i = 2; i < 8; i++) {
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(i), x, y, 160);
this.resetTextColor();
this.drawText(item.params, x + 160, y, 60, 'right');
y += lineHeight;
}
}
}

x = 0;
y = this.textPadding() * 2 + lineHeight * 7;
this.drawTextEx(item.description, x, y);
};

Window_GachaBookStatus.prototype.numberWidth = function() {
return this.textWidth('000');
};

Window_GachaBookStatus.prototype.drawItemNumber = function(item, x, y) {
this.drawText(':', x, y);
this.drawText($gameParty.numItems(item), x + this.textWidth('00'), y);
};

})();

 

sieben43

Veteran
Veteran
Joined
Oct 25, 2015
Messages
66
Reaction score
12
First Language
German, English
Primarily Uses
RMMV
I found the plugin causing that error! It's Yanfly's Item Core Plugin. Should have checked on that earlier tbh.
(Couldn't edit my previous post due to it exceeding the capacity limit.)

Edit 1: Yanfly's plugin sets the starting ID of independent items to 3000, that's why it kept checking on such a high number. Could fix it easily by setting the independent weapon ID to a much lower value.
 
Last edited:

Randy

Villager
Member
Joined
May 22, 2017
Messages
16
Reaction score
3
First Language
English
Primarily Uses
N/A
Ran into the same bug. It's probably not the ID of independent items, as I just changed that with no change in the bug. It's the fact that there are maximum items, weapons OR armor. All three of those values have to be "0". Not sure why that is the case though.
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Jeżeli jeszcze nie subskrybujecie to byłoby nam bardzo miło.
1.png
Potrzebujemy 100 subów na niestandardowy URL.
Who wants to see my review of the worst star wars movie? This movie has all the excitement of being on Jury Duty of the most boring case ever about trade negotiations.
A lot to learn to make a game. Can I handle it?
I've been working on status effects since last thursday, and today I finished the core mechanic of Zombie, Teleport, Curse and Recall. Zombie and Curse are lacking a few things to make them complete atm. Teleport though is the "HAHA" spell for some of my mobs, but can "NOPE" at them with Recall.
I'm weird as there are a few game franchises I'll watch and read about, but have no interest in playing.

Forum statistics

Threads
115,159
Messages
1,087,730
Members
149,704
Latest member
hellboy2100
Top