/
MOG_BalloonActionName.js
476 lines (441 loc) · 15.1 KB
/
MOG_BalloonActionName.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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
//===========================================================================
// MOG_BalloonActionName.js
// Translate to Japanese : fungamemake.com
//===========================================================================
/*:
* @plugindesc (v1.7) Apresenta um balão com o nome da ação.
* @author Moghunter
*
* @param Wait Mode
* @desc Esperar o balão desaparecer para continuar a batalha.
* @default true
*
* @param Duration
* @desc Duração do tempo apresentação do nome.
* @default 60
*
* @param X-Axis
* @desc Definição da posição X-Axis do balão.
* @default -10
*
* @param Y-Axis
* @desc Definição da posição Y-Axis do balão.
* @default 0
*
* @param Name X-Axis
* @desc Definição da posição X-Axis do nome.
* @default 0
*
* @param Name Y-Axis
* @desc Definição da posição Y-Axis do nome.
* @default 0
*
* @help BalloonActionName
* ===========================================================================
* +++ MOG - Balloon Action Name (v1.7) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* Apresenta um balão com o nome da ação.
* Será necessário ter o arquivo. (img/system/)
*
* ActionNameB.png
*
* ===========================================================================
* Desativar o Nome
* ===========================================================================
* Inicialmente todas as ações terão o nome ativado, no caso de querer desativar
* algum nome, utilize o comentário abaixo na caixa de notas do Item/Habilidade.
*
* Disable Balloon Name
*
* ===========================================================================
* HISTÓRICO
* ===========================================================================
* (v1.7) - Compatibilidade com MOG ATB.
* (v1.6) - Melhoria na compatibilidade com Battle Hud plugin.
* (v1.5) - Melhoria na codificação.
*
*/
/*:ja
* @plugindesc (v1.7) 行動名のバルーンを表示します。
* @author Moghunter
*
* @param Wait Mode
* @text 戦闘進行停止
* @desc バルーン表示中に戦闘進行を停止するか進行するかを決めます。
* @type boolean
* @on 停止
* @off 進行
* @default true
*
* @param Duration
* @text バルーンの表示時間
* @type number
* @max 9007
* @default 60
*
* @param X-Axis
* @text バルーンのX軸位置
* @desc 正:右 / 負:左
* @type number
* @min -9007
* @max 9007
* @default -10
*
* @param Y-Axis
* @text バルーンのY軸位置
* @desc 正:下 / 負:上
* @type number
* @min -9007
* @max 9007
* @default 0
*
* @param Name X-Axis
* @text 名前のX軸位置
* @desc 正:右 / 負:左
* @type number
* @min -9007
* @max 9007
* @default 0
*
* @param Name Y-Axis
* @text 名前のY軸位置
* @desc 正:下 / 負:上
* @type number
* @min -9007
* @max 9007
* @default 0
*
* @help
* 翻訳:ムノクラ
* https://fungamemake.com/
* https://twitter.com/munokura/
*
* ===========================================================================
* +++ MOG - Balloon Action Name (v1.7) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* 行動名のバルーンを表示します。
* 必要な画像ファイルを下記に保存してください。
* (img/system/)
*
* ActionNameB.png
* ※バルーンの画像です。行動毎に別のファイルを用意する必要はありません。
*
* ===========================================================================
* 無効化
* ===========================================================================
* アイテム/スキルのメモ欄に下記タグを入力すると非表示になります。
*
* Disable Balloon Name
*
* ===========================================================================
* 更新履歴
* ===========================================================================
* (v1.7) - MOG ATBとの互換性
* (v1.6) - Battle Hudプラグインとの互換性改善
* (v1.5) - コーディングの改善
*
*/
//===========================================================================
// ** PLUGIN PARAMETERS
//===========================================================================
var Imported = Imported || {};
Imported.MOG_BalloonActionName = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters('MOG_BalloonActionName');
Moghunter._sagaNameDuration = Number(Moghunter.parameters['Duration'] || 60);
Moghunter._sagaNameX = Number(Moghunter.parameters['X-Axis'] || -10);
Moghunter._sagaNameY = Number(Moghunter.parameters['Y-Axis'] || 0);
Moghunter._sagaNameNameX = Number(Moghunter.parameters['Name X-Axis'] || 0);
Moghunter._sagaNameNameY = Number(Moghunter.parameters['Name Y-Axis'] || 0);
Moghunter._sagaNameWait = String(Moghunter.parameters['Wait Mode'] || "false");
//===========================================================================
// ** Game Temp
//===========================================================================
//==============================
// * Initialize
//==============================
var _alias_mog_saganame_initialize = Game_Temp.prototype.initialize
Game_Temp.prototype.initialize = function () {
_alias_mog_saganame_initialize.call(this);
this._sagaNameRunning = [false, false];
this._sagaNameRunning[0] = Moghunter._sagaNameWait === "true" ? true : false;
};
//==============================
// * is Balloon NameRunning
//==============================
Game_Temp.prototype.isBalloonNameRunning = function () {
if (!$gameTemp._sagaNameRunning[0]) { return false };
if ($gameTemp._sagaNameRunning[1]) { return true };
return false;
};
//===========================================================================
// ** Game Battler
//===========================================================================
//==============================
// ** Init Members
//==============================
var _mog_saganame_gbat_initMembers = Game_Battler.prototype.initMembers;
Game_Battler.prototype.initMembers = function () {
_mog_saganame_gbat_initMembers.call(this);
this._actionNameData = [false, false, false, null];
};
//===========================================================================
// ** Battle Manager
//===========================================================================
//==============================
// ** process Turn
//==============================
var _mog_sagaName_bmng_startAction = BattleManager.startAction;
BattleManager.startAction = function () {
if (this._subject.isActor()) { this.setActionName(); };
_mog_sagaName_bmng_startAction.call(this);
};
//==============================
// * set Action Name
//==============================
BattleManager.setActionName = function () {
this._subject._actionNameData[0] = true;
if (!this._subject.currentAction() || !this._subject.currentAction().item()) { return };
var item = this._subject.currentAction().item();
var notes = item.note.split(/[\r\n]+/);
var enableName = true;
notes.forEach(function (note) {
if (note == "Disable Balloon Name") { enableName = false };
}, this);
if (enableName) {
this._subject._actionNameData = [true, true, true, item];
};
};
//==============================
// * End Turn
//==============================
var _mog_sagaName_bmngr_endAction = BattleManager.endAction;
BattleManager.endAction = function () {
_mog_sagaName_bmngr_endAction.call(this);
if (this._subject) { this._subject._actionNameData = [false, false, false, null] };
};
//===========================================================================
// ** Sprite Actor
//===========================================================================
//==============================
// * CreateLowerLayer
//==============================
var _mog_balloonAct_createUpperLayer = Spriteset_Battle.prototype.createUpperLayer
Spriteset_Battle.prototype.createUpperLayer = function () {
_mog_balloonAct_createUpperLayer.call(this);
this.createBalloonName();
};
//==============================
// * create Balloon Name
//==============================
Spriteset_Battle.prototype.createBalloonName = function () {
this._balloonField = new Sprite();
this.addChild(this._balloonField);
this._balloonName = [];
for (var i = 0; i < this._actorSprites.length; i++) {
this._balloonName[i] = new SpriteBalloonName(this._actorSprites[i]);
this._balloonField.addChild(this._balloonName[i]);
};
};
//==============================
// * Update
//==============================
var _mog_ballonAct_sprBat_update = Spriteset_Battle.prototype.update;
Spriteset_Battle.prototype.update = function () {
_mog_ballonAct_sprBat_update.call(this);
if (Imported.MOG_BattleCamera && this._balloonField) { this.updateBalloonField() };
};
//==============================
// * Update Balloon Field
//==============================
Spriteset_Battle.prototype.updateBalloonField = function () {
this._balloonField.x = this._battleField.x
this._balloonField.y = this._battleField.y
};
//===========================================================================
// * Sprite Balloon Name
//===========================================================================
function SpriteBalloonName() {
this.initialize.apply(this, arguments);
};
SpriteBalloonName.prototype = Object.create(Sprite.prototype);
SpriteBalloonName.prototype.constructor = SpriteBalloonName;
//==============================
// * Initialize
//==============================
SpriteBalloonName.prototype.initialize = function (sprite) {
Sprite.prototype.initialize.call(this);
this._sprite = sprite;
this.z = 20;
this._duration = [false, 0];
this._cwh = [-1, -1];
this.createBalloon();
this.createName();
};
//==============================
// * create Balloon
//==============================
SpriteBalloonName.prototype.createBalloon = function () {
this._balloonNameImg = ImageManager.loadSystem("ActionNameB");
this._balloon = [];
for (var i = 0; i < 4; i++) {
this._balloon[i] = new Sprite(this._balloonNameImg);
this._balloon[i].anchor.x = 0.5;
this._balloon[i].opacity = 0;
this._balloon[i].z = 20;
this.addChild(this._balloon[i]);
};
};
//==============================
// * create Name
//==============================
SpriteBalloonName.prototype.createName = function () {
this._name = new Sprite(new Bitmap(120, 32));
this._name.bitmap.fontSize = 20;
this._name.anchor.x = 0.5;
this._name.opacity = 0;
this._name.z = 21;
this.addChild(this._name);
};
//==============================
// * Battler
//==============================
SpriteBalloonName.prototype.battler = function () {
return this._sprite._battler;
};
//==============================
// * Need Refresh
//==============================
SpriteBalloonName.prototype.needRefresh = function () {
return this.battler()._actionNameData[2];
};
//==============================
// * get Sprite Data
//==============================
SpriteBalloonName.prototype.getSpriteData = function () {
this._cwh[0] = this._balloonNameImg.width;
this._cwh[1] = Math.floor(this._balloonNameImg.height / 3);
this._cwh[2] = Moghunter._sagaNameX;
this._cwh[3] = -((this._cwh[1] * 2) + 36) + Moghunter._sagaNameY;
this._name.x = Moghunter._sagaNameX + Moghunter._sagaNameNameX;
this._name.y = this._cwh[3] + Moghunter._sagaNameNameY;
};
//==============================
// * Refresh Name
//==============================
SpriteBalloonName.prototype.refreshName = function () {
$gameTemp._sagaNameRunning[1] = true;
this._sprite._battler._actionNameData[2] = false;
this._duration = [true, Moghunter._sagaNameDuration];
var text = this._sprite._battler._actionNameData[3].name;
this.refreshBalloonSprites(text);
this.refreshActionName(text);
};
//==============================
// * Refresh Action Name
//==============================
SpriteBalloonName.prototype.refreshActionName = function (text) {
this._name.opacity = 255;
this._name.bitmap.clear();
this._name.bitmap.drawText(text, 0, 0, 120, 32, 'center');
};
//==============================
// * Refresh Balloon Sprites
//==============================
SpriteBalloonName.prototype.refreshBalloonSprites = function (text) {
var textsize = Math.floor((text.length * 7) + this._cwh[0]);
var wsize = Math.min(Math.max(textsize, 48), 120);
var wposX = Math.floor((wsize / 2) + (this._cwh[0] / 2));
for (var i = 0; i < this._balloon.length; i++) {
this._balloon[i].x = this._cwh[2];
this._balloon[i].y = this._cwh[3];
this._balloon[i].opacity = 255;
if (i === 0) {
this._balloon[i].setFrame(0, 0, this._cwh[0], this._cwh[1]);
this._balloon[i].x += (this._cwh[0] / 4);
this._balloon[i].y += this._cwh[1];
} else if (i === 1) {
this._balloon[i].setFrame(0, this._cwh[1], this._cwh[0], this._cwh[1]);
this._balloon[i].scale.x = wsize / this._cwh[0];
} else if (i === 2) {
this._balloon[i].setFrame(0, this._cwh[1] * 2, this._cwh[0], this._cwh[1]);
this._balloon[i].x -= wposX;
} else if (i === 3) {
this._balloon[i].setFrame(0, this._cwh[1] * 2, this._cwh[0], this._cwh[1]);
this._balloon[i].x += wposX;
this._balloon[i].scale.x = -1;
};
};
};
//==============================
// * Update Sprites
//==============================
SpriteBalloonName.prototype.updateSprites = function () {
if (this._duration[1] > 0) {
this._duration[1]--
} else {
this._name.opacity = 0;
this._duration = [false, 0];
this._sprite._battler._actionNameData = [true, false, false, null];
$gameTemp._sagaNameRunning[1] = false;
};
for (var i = 0; i < this._balloon.length; i++) {
this._balloon[i].opacity = this._name.opacity;
};
this.x = this._sprite.x;
this.y = this._sprite.y;
};
//==============================
// * Update
//==============================
SpriteBalloonName.prototype.update = function () {
Sprite.prototype.update.call(this);
if (this._cwh[0] === -1) {
if (this._balloonNameImg.isReady()) { this.getSpriteData() };
return;
};
if (!this.battler()) { return };
if (this.needRefresh()) { this.refreshName() };
if (this._duration[0]) { this.updateSprites() };
};
if (Imported.MOG_BattleCamera) {
//==============================
// * Update Focus
//==============================
var _mog_saganame_sprbat_updateFocus = Spriteset_Battle.prototype.updateFocus;
Spriteset_Battle.prototype.updateFocus = function () {
if ($gameTemp._sagaNameRunning[1]) { $gameTemp._bcam_user[2] = 2 };
_mog_saganame_sprbat_updateFocus.call(this);
};
};
//===========================================================================
// * Scene Battle
//===========================================================================
//==============================
// * Update
//==============================
var _mog_sagaName_sbat_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function () {
if (!Imported.MOG_ATB) {
if ($gameTemp.isBalloonNameRunning()) {
this._spriteset.update();
this.updateBalloonName();
return
};
};
_mog_sagaName_sbat_update.call(this);
};
//==============================
// * Update Balloon Name
//==============================
Scene_Battle.prototype.updateBalloonName = function () {
if (Imported.MOG_BattleHud) {
for (var i = 0; i < this._battle_hud.length; i++) {
this._battle_hud[i].update()
};
}
};