-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemyAnalysisSkill.js
299 lines (291 loc) · 11.6 KB
/
EnemyAnalysisSkill.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
//=============================================================================
// RPG Maker MZ - アナライズスキル用補助プラグイン
//=============================================================================
/*:
* @target MZ
* @plugindesc Implements enemy analysis skill which tells player the enemy's weak points &c.
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/EnemyAnalysisSkill.js
*
* @param buffColor
* @text Buff emphasis color
* @desc Set text color number [0 to 31] for parameters with buff.
* @default 6
* @type number
* @min 0
* @max 31
*
* @param debuffColor
* @text Debuff emphasis color
* @desc Set text color number [0 to 31] for parameters with debuff.
* @default 4
* @type number
* @min 0
* @max 31
*
* @param labelHp
* @text HP
* @desc Set label for HP. If blank, same as the term specified in the database.
* @type string
*
* @param labelMp
* @text MP
* @desc Set label for MP. If blank, same as the term specified in the database.
* @type string
*
* @param labelAtk
* @text Attack
* @desc Set label for Attack. If blank, same as the term specified in the database.
* @default Atk
* @type string
*
* @param labelDef
* @text Defense
* @desc Set label for Defense. If blank, same as the term specified in the database.
* @default Def
* @type string
*
* @param labelMat
* @text M.Attack
* @desc Set label for M. Attack. If blank, same as the term specified in the database.
* @default MAt
* @type string
*
* @param labelMdf
* @text M.Defense
* @desc Set label for M. Defense. If blank, same as the term specified in the database.
* @default MDf
* @type string
*
* @param labelAgi
* @text Agility
* @desc Set label for Agility. If blank, same as the term specified in the database.
* @default Agi
* @type string
*
* @param labelLuk
* @text Luck
* @desc Set label for Luck. If blank, same as the term specified in the database.
* @default Luk
* @type string
*
* @help EnemyAnalysisSkill.js
*
* Implements enemy analysis skill which tells player the enemy's weak points &c.
* Set a common event which executes plugin command `analyzeEnemy`
* as effect of a battle-only skill.
* Buff/debuff for each parameter can be shown in color.
*
* Typical usage:
* - Simply "Run analysis skill". Requires no parameters.
* Target enemy character is automatically detected.
*
* License: The Unlicense
*
* Changelog
* 1 Oct 2020: Fix issue that state susceptibility is shown as [Object object]
* Insert a comma between items.
* 21 Sept 2020: Fix parameter type
* 20 Sept 2020: Fix wrong target (or crash if very first turn)
* 16 Sept 2020: Fix syntax error (parentheses mismatch)
* 14 Sept 2020: First edition.
*
* @command analyzeEnemy
* @text Run analysis skill
* @desc Runs analysis skill. Call from a common event during a battle.
*
* @command analyzeEnemyByIndex
* @text Run analysis skill (immediate value)
* @desc Runs analysis skill with manually specified target. Usually not needed.
*
* @arg enemy_index
* @type number
* @text Index of enemy character
* @desc Index of enemy character for target of the skill.
* @min 1
* @max 8
*
* @command analyzeEnemyByVariable
* @text Run analysis skill (by variable)
* @desc Runs analysis skill with variable-specified target. Usually not needed.
*
* @arg enemy_index_var
* @type variable
* @text Variable for index of enemy character
* @desc Variable that contains index of enemy character for target of the skill.
*
*/
/*:ja
* @target MZ
* @plugindesc アナライズスキル(敵の弱点とかがわかる)を実装します。
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/EnemyAnalysisSkill.js
*
* @param buffColor
* @text ステータス上昇時の文字色
* @desc ステータス上昇時の文字色を0~31で設定します。
* @default 6
* @type number
* @min 0
* @max 31
*
* @param debuffColor
* @text ステータス低下時の文字色
* @desc ステータス低下時の文字色を0~31で設定します。
* @default 4
* @type number
* @min 0
* @max 31
*
* @param labelHp
* @text HP
* @desc 「HP」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @type string
*
* @param labelMp
* @text MP
* @desc 「MP」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @type string
*
* @param labelAtk
* @text 攻撃力
* @desc 「攻撃力」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @default 攻撃
* @type string
*
* @param labelDef
* @text 防御力
* @desc 「防御力」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @default 防御
* @type string
*
* @param labelMat
* @text 魔法力
* @desc 「魔法力」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @default 魔力
* @type string
*
* @param labelMdf
* @text 魔法防御
* @desc 「魔法防御」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @default 魔防
* @type string
*
* @param labelAgi
* @text 敏捷性
* @desc 「敏捷性」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @default 敏捷
* @type string
*
* @param labelLuk
* @text 運
* @desc 「運」の表示を指定します。指定しないときはデータベースで指定した用語と同じになります。
* @default 運
* @type string
*
* @help EnemyAnalysisSkill.js
*
* アナライズスキル(敵の弱点とかがわかる)を実装します。
* コモンイベントからプラグインコマンド analyzeEnemy を実行します。
* そのコモンイベントを、戦闘中のみ使用可能なスキルの効果として設定してください。
* ステータスの強化/弱体時に色を付けて表示することもできます。
*
* 典型的な使用法:
* - 「アナライズを実行」します。引数はありません。対象は自動的に認識します。
*
* ライセンス: Unlicense
*
* 更新履歴
* 令和2年10月1日 ステート有効度の表示が[Object object]になるのを修正
* 英語版でコンマを入れるようにする
* 令和2年9月21日 パラメータの型を修正
* 令和2年9月20日 対象が正しくない(初手で使うと落ちる)のを修正
* 令和2年9月16日 文法エラー(括弧が対応していない)を修正
* 令和2年9月14日 初版
*
* @command analyzeEnemy
* @text アナライズを実行
* @desc アナライズスキルを実行します。戦闘中にコモンイベントから呼び出してください。
*
* @command analyzeEnemyByIndex
* @text アナライズを実行(直接指定)
* @desc 対象を指定してアナライズスキルを実行します。通常は使用しません。
*
* @arg enemy_index
* @type number
* @text 敵インデックス
* @desc スキルの対象となる敵インデックスを指定します。
* @min 1
* @max 8
*
* @command analyzeEnemyByVariable
* @text アナライズを実行(変数指定)
* @desc 対象を変数で指定してアナライズスキルを実行します。通常は使用しません。
*
* @arg enemy_index_var
* @type variable
* @text 敵インデックス変数
* @desc スキルの対象となる敵インデックスを格納した変数を指定します。
*
*/
(() => {
const pluginName = "EnemyAnalysisSkill";
const param = PluginManager.parameters(pluginName);
const analyzeEnemy = function(enemy) {
const isJapanese = Boolean($dataSystem.locale.match(/^ja[^[:alpha:]]?/));
// ステータスの上昇または低下時に色を付ける
const colorBuff = function(enemy, paramId) {
if (enemy.isBuffAffected(paramId)) {
return "\\C[" + param.buffColor.parseInt().toString() + "]";
} else if (enemy.isDebuffAffected(paramId)) {
return "\\C[" + param.debuffColor.parseInt().toString() + "]";
} else {
return "";
}
};
// 初期設定
$gameMessage.setFaceImage("", 0);
$gameMessage.setBackground(1);
$gameMessage.setPositionType(1);
$gameMessage.setSpeakerName("");
// 名前、HP、MP
$gameMessage.add(enemy.originalName()
+ " " + (param.labelHp || $dataSystem.terms.basic[2]) + (isJapanese ? ":" : ":") + enemy.hp.toString() + "/" + colorBuff(enemy, 0) + enemy.mhp.toString()
+ "\\C[0] " + (param.labelMp || $dataSystem.terms.basic[4]) + (isJapanese ? ":" : ":") + enemy.mp.toString() + "/" + colorBuff(enemy, 1) + enemy.mmp.toString());
// 基本パラメータ
$gameMessage.add("\\C[0]" + (param.labelAtk || $dataSystem.terms.params[2]) + ":" + colorBuff(enemy, 2) + enemy.atk.toString()
+ "\\C[0] " + (param.labelDef || $dataSystem.terms.params[3]) + ":" + colorBuff(enemy, 3) + enemy.def.toString()
+ "\\C[0] " + (param.labelMat || $dataSystem.terms.params[4]) + ":" + colorBuff(enemy, 4) + enemy.mat.toString()
+ "\\C[0] " + (param.labelMdf || $dataSystem.terms.params[5]) + ":" + colorBuff(enemy, 5) + enemy.mdf.toString()
+ "\\C[0] " + (param.labelAgi || $dataSystem.terms.params[6]) + ":" + colorBuff(enemy, 6) + enemy.agi.toString()
+ "\\C[0] " + (param.labelLuk || $dataSystem.terms.params[7]) + ":" + colorBuff(enemy, 7) + enemy.luk.toString());
// 弱点・耐性
$gameMessage.add((isJapanese ? "\\C[0]弱点:" : "\\C[0]Weak: ")
+ (enemy.traits(11).filter(trait => trait.value > 1).map(trait => $dataSystem.elements[trait.dataId]).join(isJapanese ? " " : ", ") || (isJapanese ? "なし" : "None")));
$gameMessage.add((isJapanese ? "\\C[0]耐性:" : "\\C[0]Resists: ")
+ (enemy.traits(11).filter(trait => trait.value < 1).map(trait => $dataSystem.elements[trait.dataId]).join(isJapanese ? " " : ", ") || (isJapanese ? "なし" : "None")));
// ステート耐性等
$gameMessage.add(isJapanese ? "ステート耐性・有効ステート" : "State Susceptibility");
$gameMessage.add((isJapanese ? "\\C[0]有効:" : "\\C[0]Susceptible: ")
+ (enemy.traits(13).filter(trait => trait.value > 1).map(trait => $dataStates[trait.dataId].name).concat(
enemy.traits(12).filter(trait => trait.value > 1).map(trait => $dataSystem.terms.params[trait.dataId] + (isJapanese ? "低下" : " debuff"))
).join(isJapanese ? " " : ", ") || (isJapanese ? "なし" : "None")));
$gameMessage.add((isJapanese ? "\\C[0]耐性:" : "\\C[0]Resists: ")
+ (enemy.traits(13).filter(trait => trait.value < 1).map(trait => $dataStates[trait.dataId].name).concat(
enemy.traits(12).filter(trait => trait.value < 1).map(trait => $dataSystem.terms.params[trait.dataId] + (isJapanese ? "低下" : " debuff"))
).join(isJapanese ? " " : ", ") || (isJapanese ? "なし" : "None")));
if (enemy.traits(14).length > 0) {
$gameMessage.add((isJapanese ? "\\C[18]無効:" : "\\C[18]Immune: ")
+ enemy.traits(14).map(trait => $dataStates[trait.dataId].name).join(" ") );
}
};
PluginManager.registerCommand(pluginName, "analyzeEnemy", args => {
analyzeEnemy($gameTroop.members()[$gameTemp.lastActionData(5) - 1]);
});
PluginManager.registerCommand(pluginName, "analyzeEnemyByIndex", args => {
analyzeEnemy($gameTroop.members()[parseInt(args.enemy_index)]);
});
PluginManager.registerCommand(pluginName, "analyzeEnemyByVariable", args => {
analyzeEnemy($gameTroop.members()[$gameVariables.value(parseInt(args.enemy_index_var)) - 1]);
});
})();