/
MOG_BattlebackEX.js
408 lines (382 loc) · 13.6 KB
/
MOG_BattlebackEX.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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//============================================================================
// MOG_BattlebackEX.js
// Translate to Japanese : fungamemake.com
//============================================================================
/*:
* @plugindesc (v1.2) Adiciona multiplos battlebacks no campo de batalha.
* @author Moghunter
*
* @param Cam Rate
* @desc Definição do alcance da camera.
* @default 50
*
* @param Cam Speed
* @desc Velocidade da camera.
* @default 30
*
* @param Cam Focus Delay
* @desc Definição do tempo para ativar o foco no alvo.
* @default 20
*
* @param Cam X-Axis
* @desc Definição X-axis da camera.
* @default 0
*
* @param Cam Y-Axis
* @desc Definição Y-axis da camera.
* @default 0
*
* @help
* ===========================================================================
* +++ MOG Battleback EX (v1.2) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* Adiciona multiplos battlebacks no campo de batalha.
*
* ===========================================================================
* COMANDOS DE PLUGIN
* ===========================================================================
*
* - Para mudar o alcance da camera.
*
* bb_ex : ID : FILE_NAME : PRIORITY_TYPE : Scroll_X : Scroll_Y : BLEND_MODE : CAMERA_RATE
*
* ID - Id do battleback (1 e 2 são os battlebacks padrões)
* FILE_NAME - Nome do battleback.
* PRIORITY_TYPE -
* Lower - Abaixo dos battlers.
* Upper - Acima dos battlers.
* Scroll X - Velocidade de deslize X-Axis.
* Scroll Y - Velocidade de deslize Y-Axis.
* BLEND_MODE - Tipo de Blend. (0 a 2).
* CAMERA RATE - Efeito pespectiva de 0 a 100 (Necessário o plugin Battle Camera)
*
* Exemplo.
*
* bb_ex : 3 : Clouds : Lower : 5 : 5 : 100
* bb_ex : 4 : Clouds : Upper : -10 : 0 : 80
*
* ===========================================================================
*
* Para cancelar todos os efeitos e camadas do Battleback use o comando abaixo
*
* bb_ex_clear
*
* ===========================================================================
* HISTÓRICO
* ===========================================================================
* (1.2) - Compatibilidade com RM 1.3.3.
* (1.1) - Melhoria na compatibilidade de plugins.
*/
/*:ja
* @plugindesc (v1.2.1) 複数の戦闘背景を追加レイヤー化します。
* @author Moghunter
*
* @param Cam Rate
* @text カメラ範囲
* @default 50
*
* @param Cam Speed
* @text カメラ速度
* @default 30
*
* @param Cam Focus Delay
* @text フォーカス時間
* @default 20
*
* @param Cam X-Axis
* @text カメラのX軸位置
* @desc 正:右 / 負:左
* @type number
* @min -9007
* @max 9007
* @default 0
*
* @param Cam Y-Axis
* @text カメラのY軸位置
* @desc 正:下 / 負:上
* @type number
* @min -9007
* @max 9007
* @default 0
*
* @help
* 翻訳:ムノクラ
* https://fungamemake.com/
* https://twitter.com/munokura/
*
* ===========================================================================
* +++ MOG Battleback EX (v1.2.1) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* 複数の戦闘背景を追加レイヤー化します。
*
* ===========================================================================
* 注意
* ===========================================================================
* このプラグインを単体で使用すると、戦闘背景1,2のY軸が正常に動作しません。
* MOG Battle Cameraプラグインを併用すると、このバグは発生しなくなります。
*
* ===========================================================================
* プラグインコマンド
* ===========================================================================
*
* - カメラの範囲を変更します。
*
* bb_ex : ID : FILE_NAME : PRIORITY_TYPE : Scroll_X : Scroll_Y : BLEND_MODE : CAMERA_RATE
*
* ID - 戦闘背景ID (1と2は標準の戦闘背景です)
* FILE_NAME - 戦闘背景のファイル名 (/img/battlebacks1 内に保存)
* PRIORITY_TYPE - 優先順 (Lower:バトラーの下 / Upper:バトラーの上)
* Scroll X - X軸の移動速度
* Scroll Y - Y軸の移動速度
* BLEND_MODE - 合成方法 (0:通常 / 1:加算 / 2:乗算)
* CAMERA RATE - 0から100までの遠近効果 (要MOG Battle Cameraプラグイン)
*
* 例
*
* bb_ex : 3 : Clouds : Lower : 5 : 5 : 100
* bb_ex : 4 : Clouds : Upper : -10 : 0 : 80
*
* ===========================================================================
*
* 戦闘背景のすべての効果とレイヤーをキャンセルするには、
* 以下のコマンドを使います。
*
* bb_ex_clear
*
* ===========================================================================
* 更新履歴
* ===========================================================================
* (1.2) - RM 1.3.3との互換性
* (1.1) - プラグインの互換性向上
*/
//============================================================================
// ** PLUGIN PARAMETERS
//============================================================================
var Imported = Imported || {};
Imported.MOG_BattlebackEX = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters('MOG_BattlebackEX');
//============================================================================
// ** Game_System
//============================================================================
//==============================
// * Initialize
//==============================
var _alias_mog_bbex_sys_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () {
_alias_mog_bbex_sys_initialize.call(this);
this._bbex_data = [];
};
//============================================================================
// ** Game_Interpreter
//============================================================================
//==============================
// * PluginCommand
//==============================
var _alias_mog_bbex_pluginCommand = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function (command, args) {
_alias_mog_bbex_pluginCommand.call(this, command, args)
if (command === "bb_ex") {
var index = Math.min(Math.max(args[1], 1), 100); index -= 1;
$gameSystem._bbex_data[index] = [];
$gameSystem._bbex_data[index][0] = String(args[3]);
$gameSystem._bbex_data[index][1] = String(args[5]);
$gameSystem._bbex_data[index][2] = Number(args[7]);
$gameSystem._bbex_data[index][3] = Number(args[9]);
$gameSystem._bbex_data[index][4] = Math.min(Math.max(Number(args[11]), 0), 2);
if (args[13]) {
var rate = Math.min(Math.max(Number(args[13]), -100), 100)
$gameSystem._bbex_data[index][5] = rate;
}
};
if (command === "bb_ex_clear") { $gameSystem._bbex_data = [] };
return true;
};
//============================================================================
// ** SpritesetBattle Prototype
//============================================================================
var _alias_mog_sprt_createBattleField = Spriteset_Battle.prototype.createBattleField;
Spriteset_Battle.prototype.createBattleField = function () {
_alias_mog_sprt_createBattleField.call(this);
this.bbexSetup();
};
//============================================================================
// ** BbexSetup
//============================================================================
Spriteset_Battle.prototype.bbexSetup = function () {
this._bbexcfix = Utils.RPGMAKER_VERSION >= "1.3.3" ? true : false;
this._bbData = [];
for (var i = 0; i < $gameSystem._bbex_data.length; i++) {
if (i === 0 && !$gameSystem._bbex_data[0]) { this._bbData.push($gameSystem._bbex_data[0]) };
if (i === 1 && !$gameSystem._bbex_data[1]) { this._bbData.push($gameSystem._bbex_data[1]) };
if ($gameSystem._bbex_data[i]) { this._bbData.push($gameSystem._bbex_data[i]) };
};
this._bbPlaneLower = new Sprite();
this._bbPlaneLower.z = 0;
this._battleField.addChild(this._bbPlaneLower);
};
//==============================
// * createBBUperPlane
//==============================
Spriteset_Battle.prototype.createBbUpperPlane = function () {
this._bbPlaneUpper = new Sprite();
this._bbPlaneUpper.z = 10;
this._battleField.addChild(this._bbPlaneUpper);
};
//==============================
// * setbbBitmap
//==============================
Spriteset_Battle.prototype.setbbBitmap = function (index) {
if (this._bbData[index][1] === "Lower") {
return ImageManager.loadBattleback1(this._bbData[index][0]);
} else {
return ImageManager.loadBattleback2(this._bbData[index][0]);
};
};
//==============================
// * createActors
//==============================
var _alias_mog_bbex_createActors = Spriteset_Battle.prototype.createActors
Spriteset_Battle.prototype.createActors = function () {
_alias_mog_bbex_createActors.call(this);
this.createBbUpperPlane();
};
//==============================
// * createLower Layer
//==============================
var _alias_mog_bbex_sprtbat_createLowerLayer = Spriteset_Battle.prototype.createLowerLayer
Spriteset_Battle.prototype.createLowerLayer = function () {
_alias_mog_bbex_sprtbat_createLowerLayer.call(this);
this.createBattlebacks();
};
//==============================
// * createBattlebacks
//==============================
Spriteset_Battle.prototype.createBattlebacks = function () {
this.addBattleback(this._back1Sprite, 0);
this.addBattleback(this._back2Sprite, 1);
this._backSpriteEx = [];
for (var i = 2; i < this._bbData.length; i++) {
this._backSpriteEx[i] = new TilingSprite();
this.addBattleback(this._backSpriteEx[i], i);
};
};
//==============================
// * add BattleBack
//==============================
Spriteset_Battle.prototype.addBattleback = function (sprite, index) {
var margin = 32;
var x = -this._battleField.x - margin;
var y = -this._battleField.y - margin;
var width = Graphics.width + margin * 2;
var height = Graphics.height + margin * 2;
if (this._bbData[index]) {
sprite.bitmap = this.setbbBitmap(index)
} else {
if (index === 0) {
sprite.bitmap = this.battleback1Bitmap();
} else {
sprite.bitmap = this.battleback2Bitmap();
};
};
sprite.move(x, y, width, height);
this.setbbexOrgInit(sprite);
if (!this._bbData[index] || this._bbData[index][1] === "Lower") {
this._bbPlaneLower.addChild(sprite);
} else {
this._bbPlaneUpper.addChild(sprite);
};
if (this._bbData[index]) { sprite.blendMode = this._bbData[index][4] };
};
//==============================
// * createBattleback
//==============================
Spriteset_Battle.prototype.createBattleback = function () {
this._back1Sprite = new TilingSprite();
this.setbbexOrgInit(this._back1Sprite);
this._back2Sprite = new TilingSprite();
this.setbbexOrgInit(this._back2Sprite);
};
//==============================
// * setBBexOrgInt
//==============================
Spriteset_Battle.prototype.setbbexOrgInit = function (sprite) {
sprite.init = 0;
sprite.ox = 0;
sprite.oy = 0;
sprite.ow = this._bbexcfix ? Graphics.width / 2 : 0;
sprite.oh = this._bbexcfix ? Graphics.height / 2 : 0;
sprite.origin.x = sprite.ow;
sprite.origin.y = sprite.oh;
};
//==============================
// * Is BBEX Visible
//==============================
Spriteset_Battle.prototype.isbbEXVisible = function (sprite) {
if (!Imported.MOG_BattleCamera) { return true }
if (!this._bbexcfix) { return true }
if (!sprite.bitmap) { return false };
if (!sprite.bitmap.isReady()) { return false };
if (!sprite.init) { return false };
return true
};
//==============================
// * updateBBEXVisible
//==============================
Spriteset_Battle.prototype.updateBBEXVisible = function (sprite) {
sprite.visible = false;
if (sprite.bitmap.isReady()) { this.setBBEXVisible(sprite) };
};
//==============================
// * set BBEX Visible
//==============================
Spriteset_Battle.prototype.setBBEXVisible = function (sprite) {
sprite.visible = true;
sprite.init = true;
sprite.ow = sprite.bitmap.width / 2;
sprite.oh = sprite.bitmap.height / 2;
sprite.origin.x = sprite.ow;
sprite.origin.y = sprite.oh;
};
//==============================
// * updateBattleback
//==============================
var _alias_mog_bbex_updateBattleback = Spriteset_Battle.prototype.updateBattleback;
Spriteset_Battle.prototype.updateBattleback = function () {
_alias_mog_bbex_updateBattleback.call(this);
this.updateBattlebackEffects();
};
//==============================
// * updateScroll
//==============================
Spriteset_Battle.prototype.updateScroll = function (sprite, index) {
sprite.ox += this._bbData[index][2];
sprite.oy += this._bbData[index][3];
sprite.origin.x = sprite.ox + sprite.ow;
sprite.origin.y = sprite.oy + sprite.oh;
};
//==============================
// * update BBEX Opacity
//==============================
Spriteset_Battle.prototype.updateBBEXOpacity = function (sprite) {
if (!this._back1Sprite) { return };
sprite.opacity = this._back1Sprite.opacity;
};
//==============================
// * updateBattlebackEffects
//==============================
Spriteset_Battle.prototype.updateBattlebackEffects = function () {
if (!this.isbbEXVisible(this._back1Sprite)) { this.updateBBEXVisible(this._back1Sprite) };
if (!this.isbbEXVisible(this._back2Sprite)) { this.updateBBEXVisible(this._back2Sprite) };
if (this._bbData[0]) { this.updateScroll(this._back1Sprite, 0); };
if (this._bbData[1]) { this.updateScroll(this._back2Sprite, 1); };
for (var i = 2; i < this._bbData.length; i++) {
if (!this.isbbEXVisible(this._backSpriteEx[i])) { this.updateBBEXVisible(this._backSpriteEx[i]) };
this.updateScroll(this._backSpriteEx[i], i);
this.updateBBEXOpacity(this._backSpriteEx[i]);
};
};