/
MOG_EnemyPoses.js
298 lines (269 loc) · 9.88 KB
/
MOG_EnemyPoses.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
//===========================================================================
// MOG_EnemyPoses.js
// Translate to Japanese : fungamemake.com
//===========================================================================
/*:
* @plugindesc (v1.4) Adiciona poses nos battlers dos inimigos.
* @author Moghunter
*
* @help
* ===========================================================================
* +++ MOG Enemy Poses (v1.4) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* Adiciona poses nos battlers dos inimigos.
*
* ===========================================================================
* UTILIZAÇÃO
* ===========================================================================
* Para ativar as poses basta adicionar esse comentário na caixa de notas do
* inimigo.
*
* Battler Poses
*
* ===========================================================================
* NOMEAÇÃO DA IMAGEM
* ===========================================================================
* Será necessário ter uma imagem com as poses do battler, essa imagem deverá
* ter o sufixo [Poses]
*
* E.g
*
* Slime.png
* Slime[Poses].png
*
* ===========================================================================
* - WHAT'S NEW (version 1.4)
* ===========================================================================
* (NEW) - Compatibilidade com Battler Motion v2.0
*
*/
/*:ja
* @plugindesc (v1.4) 戦闘中の敵にポーズを追加します。
* @author Moghunter
*
* @help
* 翻訳:ムノクラ
* https://fungamemake.com/
* https://twitter.com/munokura/
*
* ===========================================================================
* +++ MOG Enemy Poses (v1.4) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* 戦闘中の敵にポーズを追加します。
*
* ===========================================================================
* メモタグ
* ===========================================================================
* ポーズを有効にするには、敵のメモ欄に下記のタグを追加してください。
*
* Battler Poses
*
* ===========================================================================
* 必要ファイル
* ===========================================================================
* ポーズ画像が必要です。
* この画像にはファイル名の最後に[Poses]が必要です
*
* 例
*
* Slime.png
* Slime[Poses].png
*
* ポーズ画像は元の画像と同じ幅の画像を4種類用意し、横に結合したファイルです。
* ・待機
* ・回復
* ・攻撃
* ・被ダメージ及び残HP低
* の4種です。
*
* ===========================================================================
* - 更新履歴 (version 1.4)
* ===========================================================================
* (NEW) - Battler Motion v2.0との互換性
*
*/
//===========================================================================
// ** PLUGIN PARAMETERS
//===========================================================================
//===========================================================================
// ** PLUGIN PARAMETERS
//===========================================================================
var Imported = Imported || {};
Imported.MOG_EnemyPoses = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters('MOG_EnemyPoses');
//===========================================================================
// ** Game_Battler
//===========================================================================
//==============================
// * Init Members
//==============================
var _mog_battlerposes_gbat_initMembers = Game_Battler.prototype.initMembers;
Game_Battler.prototype.initMembers = function () {
_mog_battlerposes_gbat_initMembers.call(this);
this._batPoses = [false, 0, 0, -1, false];
};
//==============================
// * setBPose
//==============================
Game_Battler.prototype.setBPose = function (pose) {
this._batPoses[1] = pose;
this._batPoses[2] = pose === 2 ? 120 : 60;
};
//==============================
// * isBPose
//==============================
Game_Battler.prototype.isBPose = function (pose) {
return this._batPoses[0];
};
//==============================
// * Force Action
//==============================
var _mog_batposes_forceAction = Game_Battler.prototype.forceAction;
Game_Battler.prototype.forceAction = function (skillId, targetIndex) {
this.setBPose(2);
_mog_batposes_forceAction.call(this, skillId, targetIndex);
};
//==============================
// * Notetags
//==============================
Game_Battler.prototype.notetags = function () {
if (this.isEnemy()) { return this.enemy().note.split(/[\r\n]+/) };
if (this.isActor()) { return this.actor().note.split(/[\r\n]+/) };
};
//==============================
// * check Bat Poses
//==============================
Game_Battler.prototype.checkBatPoses = function () {
this.notetags().forEach(function (note) {
if (note === "Battler Poses") { this._batPoses[0] = true; };
}, this);
};
//===========================================================================
// ** Game Enemy
//===========================================================================
//==============================
// * Setup
//==============================
var _mog_batposes_setup = Game_Enemy.prototype.setup;
Game_Enemy.prototype.setup = function (enemyId, x, y) {
_mog_batposes_setup.call(this, enemyId, x, y);
this.checkBatPoses();
};
//==============================
// * Transform
//==============================
var _alias_batposes_transform = Game_Enemy.prototype.transform
Game_Enemy.prototype.transform = function (enemyId) {
_alias_batposes_transform.call(this, enemyId)
var enmy = $dataEnemies[enemyId]
var enmynotes = enmy.note.split(/[\r\n]+/)
this._batPoses = [false, 0, 0, -1, false];
enmynotes.forEach(function (note) {
if (note === "Battler Poses") { this._batPoses[0] = true; };
}, this);
};
//===========================================================================
// ** Sprite Enemy
//===========================================================================
//==============================
// * loadBitmap
//==============================
var _mog_batposes_sprenemy_loadBitmap = Sprite_Enemy.prototype.loadBitmap;
Sprite_Enemy.prototype.loadBitmap = function (name, hue) {
if (this._battler && this._battler.isBPose()) { name = name + "[Poses]" }
this._battler._batPoses[3] = -1;
this.visible = false;
_mog_batposes_sprenemy_loadBitmap.call(this, name, hue);
};
//==============================
// * updateFrame
//==============================
var _mog_batpose_sprenemy_updateFrame = Sprite_Enemy.prototype.updateFrame;
Sprite_Enemy.prototype.updateFrame = function () {
if (this._battler.isBPose()) { this.updateFramePoses(); return };
_mog_batpose_sprenemy_updateFrame.call(this);
};
//==============================
// * getPoseData
//==============================
Sprite_Enemy.prototype.getPoseData = function () {
this._battler._batPoses[3] = this.bitmap.width / 4;
this.batPosesIdle();
this.visible = true;
};
//==============================
// * Pose Width
//==============================
Sprite_Enemy.prototype.poseWidth = function () {
return this._battler._batPoses[3];
};
//==============================
// * Pose Index
//==============================
Sprite_Enemy.prototype.poseIndex = function () {
return this._battler._batPoses[1] * this._battler._batPoses[3];
};
//==============================
// * Bat Poses Iddle
//==============================
Sprite_Enemy.prototype.batPosesIdle = function () {
var lowHp = Math.floor(this._battler.mhp * 33 / 100);
this._battler._batPoses[1] = this._battler.hp <= lowHp ? 3 : 0;
this._battler._batPoses[2] = 0;
};
//==============================
// * updatePoseDuration
//==============================
Sprite_Enemy.prototype.updatePoseDuration = function () {
this._battler._batPoses[2] -= 1;
if (this._battler._batPoses[2] === 0) { this.batPosesIdle() };
};
//==============================
// * updateFramePoses
//==============================
Sprite_Enemy.prototype.updateFramePoses = function () {
if (this.poseWidth() === -1 && this.bitmap.isReady()) { this.getPoseData() };
if (this.poseWidth() === -1) { return };
if (this._battler._batPoses[2] > 0) { this.updatePoseDuration() };
var frameHeight = this.bitmap.height;
if (this._effectType === 'bossCollapse') { frameHeight = this._effectDuration; };
this.setFrame(this.poseIndex(), 0, this.poseWidth(), frameHeight);
};
//===========================================================================
// ** Game Action
//===========================================================================
//==============================
// * Apply
//==============================
var _mog_batposes_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function (target) {
var oldhp = target.hp;
_mog_batposes_apply.call(this, target);
if (oldhp > target.hp && this.item().damage.type != 0) {
target.setBPose(3);
} else if (oldhp < target.hp) { target.setBPose(1) };
};
//==============================
// * Prepare
//==============================
var _mog_batposes_action_prepare = Game_Action.prototype.prepare
Game_Action.prototype.prepare = function () {
_mog_batposes_action_prepare.call(this);
if (this.subject()) { this.subject().setBPose(2); };
};
//===========================================================================
// ** BattleManager
//===========================================================================
//==============================
// * endAction
//==============================
var _mog_batpose_Bmgr_endAction = BattleManager.endAction;
BattleManager.endAction = function () {
if (this._subject) { this._subject._batPoses[2] = 1 };
_mog_batpose_Bmgr_endAction.call(this);
};