168 lines
7.2 KiB
JavaScript
168 lines
7.2 KiB
JavaScript
//=============================================================================
|
||
// MagicItems.js
|
||
//=============================================================================
|
||
|
||
/*:ja
|
||
* @plugindesc ver1.04 アイテムMPコストォ・・・
|
||
* @author まっつUP
|
||
*
|
||
* @help
|
||
*
|
||
* RPGで笑顔を・・・
|
||
*
|
||
* このヘルプとパラメータの説明をよくお読みになってからお使いください。
|
||
* パラメータとプラグインコマンドはありません。
|
||
*
|
||
* アイテムのノートタグ
|
||
* <MIpay: x>
|
||
*
|
||
* xの部分に1以上の値を入れるとMPコストが表示されます。
|
||
* 0以下を指定すると表示されなかったり、MPが回復したりします。
|
||
* また、MPコストはそのアクターの特殊能力値「MP消費率」によって変動します。
|
||
*
|
||
* ver1.01 透明度変更判定のためにそのアクターの取得を追加。
|
||
* ver1.02 バトル中にはメニュー条件以外の大事なものでないアイテムを全て表示するように変更。
|
||
* ver1.03 アイテムMPコストの後ろにMP(略)を追加(データベース参照)
|
||
* ver1.04 一定条件下でショップ、装備、アイテム選択処理の時に落ちるのを防ぐための処置。
|
||
*
|
||
* 免責事項:
|
||
* このプラグインを利用したことによるいかなる損害も制作者は一切の責任を負いません。
|
||
*
|
||
*/
|
||
|
||
(function() {
|
||
|
||
var parameters = PluginManager.parameters('MagicItems');
|
||
|
||
Game_BattlerBase.prototype.itemMpCost = function(item) { //新規
|
||
var mip = Number($dataItems[item.id].meta['MIpay'] || 0);
|
||
return Math.floor(mip * this.mcr);
|
||
};
|
||
|
||
Game_BattlerBase.prototype.canPayitemCost = function(item) { //新規、判定用
|
||
return this._mp >= this.itemMpCost(item);
|
||
};
|
||
|
||
Game_BattlerBase.prototype.payitemCost = function(item) { //新規
|
||
this._mp -= this.itemMpCost(item);
|
||
};
|
||
|
||
Game_BattlerBase.prototype.meetsItemConditions = function(item) { //新規の条件を追加
|
||
return this.meetsUsableItemConditions(item) && $gameParty.hasItem(item) && this.canPayitemCost(item);
|
||
};
|
||
|
||
Game_Battler.prototype.useItem = function(item) {
|
||
if (DataManager.isSkill(item)) {
|
||
this.paySkillCost(item);
|
||
} else if (DataManager.isItem(item)) {
|
||
this.payitemCost(item); //新規の処理を追加
|
||
this.consumeItem(item);
|
||
}
|
||
};
|
||
|
||
// Scene_Menu.prototype.createCommandWindow = function() {
|
||
// this._commandWindow = new Window_MenuCommand(0, 0);
|
||
// this._commandWindow.setHandler('item', this.commandPersonal.bind(this)); //個人コマンドへ
|
||
// this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));
|
||
// this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));
|
||
// this._commandWindow.setHandler('status', this.commandPersonal.bind(this));
|
||
// this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
|
||
// this._commandWindow.setHandler('options', this.commandOptions.bind(this));
|
||
// this._commandWindow.setHandler('save', this.commandSave.bind(this));
|
||
// this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
|
||
// this._commandWindow.setHandler('cancel', this.popScene.bind(this));
|
||
// this.addWindow(this._commandWindow);
|
||
// };
|
||
|
||
Scene_Menu.prototype.onPersonalOk = function() {
|
||
switch (this._commandWindow.currentSymbol()) {
|
||
case 'item': //追加
|
||
SceneManager.push(Scene_Item);
|
||
break;
|
||
case 'skill':
|
||
SceneManager.push(Scene_Skill);
|
||
break;
|
||
case 'equip':
|
||
SceneManager.push(Scene_Equip);
|
||
break;
|
||
case 'status':
|
||
SceneManager.push(Scene_Status);
|
||
break;
|
||
}
|
||
};
|
||
|
||
Scene_Item.prototype.refreshActor = function() { //新規
|
||
var actor = this.actor();
|
||
this._itemWindow.setActor(actor); //新規の処理(Window_ItemList.prototype.setActor)
|
||
};
|
||
|
||
Scene_Item.prototype.createItemWindow = function() {
|
||
var wy = this._categoryWindow.y + this._categoryWindow.height;
|
||
var wh = Graphics.boxHeight - wy;
|
||
this._itemWindow = new Window_ItemList(0, wy, Graphics.boxWidth, wh);
|
||
this.refreshActor(); //新規の処理を追加
|
||
this._itemWindow.setHelpWindow(this._helpWindow);
|
||
this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
|
||
this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
|
||
this.addWindow(this._itemWindow);
|
||
this._categoryWindow.setItemWindow(this._itemWindow);
|
||
};
|
||
|
||
Scene_Item.prototype.user = function() { //大幅書き換え
|
||
return this.actor();
|
||
};
|
||
|
||
Window_ItemList.prototype.setActor = function(actor) { //新規(Scene_Item.prototype.refreshActorから)
|
||
if (this._actor !== actor) {
|
||
this._actor = actor;
|
||
this.refresh();
|
||
this.resetScroll();
|
||
}
|
||
};
|
||
|
||
// 上書きする前の関数を保持
|
||
var _Window_ItemList_makeItemList = Window_ItemList.prototype.makeItemList;
|
||
Window_ItemList.prototype.makeItemList = function() {
|
||
if ($gameParty.inBattle()) this._actor = BattleManager.actor(); //戦闘中はバトルマネージャから直接取得
|
||
// 保持したおいた関数を呼び出す
|
||
_Window_ItemList_makeItemList.apply(this, arguments);
|
||
};
|
||
|
||
Window_ItemList.prototype.isEnabled = function(item) { //大幅書き換え
|
||
//if ($gameParty.inBattle()) this._actor = BattleManager.actor();
|
||
return this._actor && this._actor.canUse(item);
|
||
};
|
||
|
||
Window_ItemList.prototype.drawItem = function(index) {
|
||
var item = this._data[index];
|
||
if (item) {
|
||
var numberWidth = this.numberWidth();
|
||
var costWidth = 64; //追加
|
||
var rect = this.itemRect(index);
|
||
rect.width -= this.textPadding();
|
||
this.changePaintOpacity(this.isEnabled(item));
|
||
this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth - costWidth); //幅を変更
|
||
this.drawitemCost(item, rect.x, rect.y, rect.width - numberWidth); //追加
|
||
this.drawItemNumber(item, rect.x, rect.y, rect.width);
|
||
this.changePaintOpacity(1);
|
||
}
|
||
};
|
||
|
||
Window_ItemList.prototype.drawitemCost = function(item, x, y, width) { //新規、本処理
|
||
if ($gameParty.inBattle()) this._actor = BattleManager.actor(); //戦闘中はバトルマネージャから直接取得
|
||
//console.log(this._actor)
|
||
if (this._actor) { //私はundefinedを一生許さないだろう
|
||
if (this._actor.itemMpCost(item) > 0) {
|
||
this.changeTextColor(this.mpCostColor());
|
||
this.drawText(this._actor.itemMpCost(item) + TextManager.mpA, x, y, width, 'right'); //コストの値とMP略称を表示。
|
||
this.resetTextColor();
|
||
}
|
||
}
|
||
};
|
||
|
||
Window_BattleItem.prototype.includes = function(item) { //バトル中におけるパーティ単位での項目追加可否確認は削除
|
||
//return $gameParty.canUse(item);
|
||
return DataManager.isItem(item) && item.itypeId === 1 && this._actor.isOccasionOk(item); //大事なものではないアイテムか。
|
||
};
|
||
|
||
})();
|