forked from triacontane/RPGMakerMV
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAddSubCategoryWeapon.js
80 lines (73 loc) · 3.36 KB
/
AddSubCategoryWeapon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//=============================================================================
// AddSubCategoryWeapon.js
// ----------------------------------------------------------------------------
// Copyright (c) 2015 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.0.1 2016/05/04 もともと武器や防具が表示されなくなってしまう不具合を修正
// 1.0.0 2016/05/03 初版
// ----------------------------------------------------------------------------
// [Blog] : http://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================
/*:
* @plugindesc サブ武器カテゴリー追加プラグイン
* @author トリアコンタン
*
* @param 装備タイプID
* @desc サブ武器に該当する装備タイプIDです。
* @default 2
*
* @help サブ武器のカテゴリーを追加します。
* パラメータに指定した装備タイプIDで「防具」を作成すると
* アイテムの一覧では「武器」のカテゴリーに表示されるようになります。
*
* このプラグインにはプラグインコマンドはありません。
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
(function () {
'use strict';
var pluginName = 'AddSubCategoryWeapon';
var getParamNumber = function(paramNames, min, max) {
var value = getParamOther(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(value, 10) || 0).clamp(min, max);
};
var getParamOther = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i < paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames[i]];
if (name) return name;
}
return null;
};
//=============================================================================
// パラメータの取得と整形
//=============================================================================
var paramEquipTypeId = getParamNumber(['EquipTypeId', '装備タイプID']);
//=============================================================================
// Window_ItemList
// サブ武器にあたる防具を「武器」カテゴリに表示します。
//=============================================================================
var _Window_ItemList_includes = Window_ItemList.prototype.includes;
Window_ItemList.prototype.includes = function(item) {
var result = _Window_ItemList_includes.apply(this, arguments);
switch (this._category) {
case 'weapon':
if (DataManager.isArmor(item) && item.etypeId === paramEquipTypeId) result = true;
break;
case 'armor':
if (DataManager.isArmor(item) && item.etypeId === paramEquipTypeId) result = false;
break;
}
return result;
};
})();