/
MOG_DmgPopupEffects.js
483 lines (442 loc) · 14.5 KB
/
MOG_DmgPopupEffects.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
476
477
478
479
480
481
482
483
//===========================================================================
// MOG_DmgPopupEffects.js
// Translate to Japanese : fungamemake.com
//===========================================================================
/*:
* @plugindesc (v1.0) Adiciona alguns efeitos nos sprites do dano.
* @author Moghunter
*
* @param Duration
* @desc Duração do dano.
* @default 90
*
* @param PopUp Type
* @desc Tipo de Animação.
* 0 - Bouncing 1 - Flying
* @default 0
*
* @param Zoom Effect
* @desc Ativar efeito de Zoom.
* @default true
*
* @param Center Y-Axis
* @desc Centralizar a posição do dano baseado na altura do battler.
* @default true
*
* @help
* ===========================================================================
* +++ MOG - Damage Popup Effects (v1.0) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* Adiciona alguns efeitos nos sprites do dano e novas Strings.
*
* É necessário que a imagem tenha a altura dividida por 8 para que as imagens
* fiquem alinhadas. (O padrão é 5)
*
* ===========================================================================
* É possível ajustar a posição do dano usando o comentário abaixo na
* caixa de notas.
*
* Damage Offset: X:Y
*
* Exemplo
*
* Damage Offset: 60:20
*
*/
/*:ja
* @plugindesc (v1.0) ダメージ表示を拡張します。
* @author Moghunter
*
* @param Duration
* @text ダメージの表示時間
* @default 90
*
* @param PopUp Type
* @text アニメーションの種類
* @desc 0:バウンド / 1:フライング
* @type select
* @option バウンド
* @value 0
* @option フライング
* @value 1
* @default 0
*
* @param Zoom Effect
* @text ズーム効果の有効化
* @type boolean
* @on 有効
* @off 無効
* @default true
*
* @param Center Y-Axis
* @text 表示Y位置の中央揃え有効化
* @desc ダメージ表示位置をバトラーの高さに合わせる機能
* @type boolean
* @on 有効
* @off 無効
* @default true
*
* @help
* 翻訳:ムノクラ
* https://fungamemake.com/
* https://twitter.com/munokura/
*
* ===========================================================================
* +++ MOG - Damage Popup Effects (v1.0) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* ===========================================================================
* ダメージ画像(\img\system\Damage.png)を変更する必要があります。
*
* 画像(Damage.png)の内容を8行分にする必要があります。(デフォルトは5行)
* 上から順に下記になります。
* ・ダメージ数字色1
* ・ダメージ数字色2
* ・ダメージ数字色3
* ・ダメージ数字色4
* ・ミス
* ・会心
* ・反撃
* ・反射
*
* 参考
* デフォルト画像のサイズ 240 x 160 px (文字毎の高さ32px)
* サンプルプロジェクト画像のサイズ 200 x 232 px (文字毎の高さ29px)
*
* ===========================================================================
* 下のメモタグを使ってダメージの位置を調整できます。
*
* Damage Offset: X:Y
*
* 例
*
* Damage Offset: 60:20
*
*/
//===========================================================================
// ** PLUGIN PARAMETERS
//===========================================================================
var Imported = Imported || {};
Imported.MOG_DmgPopupEffects = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters('MOG_DmgPopupEffects');
Moghunter.dmgp_duration = Number(Moghunter.parameters['Duration'] || 90);
Moghunter.dmgp_popup_type = Number(Moghunter.parameters['PopUp Type'] || 0);
Moghunter.dmgp_zoom_effect = String(Moghunter.parameters['Zoom Effect'] || "true");
Moghunter.dmgp_center_y = String(Moghunter.parameters['Center Y-Axis'] || "true");
//===========================================================================
// ** Game Action Result
//===========================================================================
//==============================
// ** Clear
//==============================
var _mog_dmgpop_gaction_clear = Game_ActionResult.prototype.clear
Game_ActionResult.prototype.clear = function () {
_mog_dmgpop_gaction_clear.call(this);
this.counter = false;
this.reflection = false;
};
//===========================================================================
// ** Game Battler
//===========================================================================
var _mog_dmgpop_gbat_initMembers = Game_Battler.prototype.initMembers;
Game_Battler.prototype.initMembers = function () {
_mog_dmgpop_gbat_initMembers.call(this);
this._dmgOffsetX = 0;
this._dmgOffsetY = 0;
};
//==============================
// ** perform Counter
//==============================
var _mog_dmgpop_gbat_performCounter = Game_Battler.prototype.performCounter;
Game_Battler.prototype.performCounter = function () {
_mog_dmgpop_gbat_performCounter.call(this);
this.startDamagePopup();
this._result.counter = true;
};
//==============================
// ** perform Reflection
//==============================
var _mog_dmgpop_gbat_performReflection = Game_Battler.prototype.performReflection;
Game_Battler.prototype.performReflection = function () {
_mog_dmgpop_gbat_performReflection.call(this);
this.startDamagePopup();
this._result.reflection = true;
};
//==============================
// * 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]+/) };
};
//==============================
// * setDmgOffset
//==============================
Game_Battler.prototype.setDmgOffset = function () {
this.notetags().forEach(function (note) {
var note_data = note.split(': ');
if (note_data[0].toLowerCase() == "damage offset") {
var par = note_data[1].split(':');
this._dmgOffsetX = Number(par[0]);
this._dmgOffsetY = Number(par[1]);
}
}, this);
};
//===========================================================================
// ** Game Actor
//===========================================================================
//==============================
// * Setup
//==============================
var _mog_dmgpop_gact_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function (actorId) {
_mog_dmgpop_gact_setup.call(this, actorId);
this.setDmgOffset();
};
//===========================================================================
// ** Game Enemy
//===========================================================================
//==============================
// * Setup
//==============================
var _mog_dmgpop_gemy_setup = Game_Enemy.prototype.setup;
Game_Enemy.prototype.setup = function (enemyId, x, y) {
_mog_dmgpop_gemy_setup.call(this, enemyId, x, y);
this.setDmgOffset();
};
//===========================================================================
// ** Sprite Damage
//===========================================================================
//==============================
// ** initialize
//==============================
var _mog_dmgpopeffect_sprit_dmg_initialize = Sprite_Damage.prototype.initialize;
Sprite_Damage.prototype.initialize = function () {
_mog_dmgpopeffect_sprit_dmg_initialize.call(this);
this._duration = Math.min(Math.max(Moghunter.dmgp_duration, 10), 999);
this._zoomEffect = String(Moghunter.dmgp_zoom_effect) === "true" ? true : false;
this._animeType = Math.min(Math.max(Moghunter.dmgp_popup_type, 0), 2);
this._damage = [0, 0];
};
//==============================
// ** Setup
//==============================
var _mog_dmgpop_sprdmg_setup = Sprite_Damage.prototype.setup;
Sprite_Damage.prototype.setup = function (target) {
_mog_dmgpop_sprdmg_setup.call(this, target);
var result = target.result();
if (result.counter) {
this.createCounter()
} else if (result.reflection) { this.createReflection() };
};
//==============================
// ** Create Miss
//==============================
Sprite_Damage.prototype.createMiss = function () {
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(0, 4 * h, 10 * w, h);
sprite.dy = 0;
sprite.x = (6 * w) / 2;
};
//==============================
// ** Create Critical
//==============================
Sprite_Damage.prototype.createCritical = function () {
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(0, 5 * h, 10 * w, h);
sprite.dy = 0;
sprite.yf2 = h + 5;
if (this._zoomEffect && this._animeType === 1) {
sprite.yf3 = 16;
sprite.rotation = 0.1;
};
sprite.x = (5 * w) / 2;
};
//==============================
// ** Create Counter
//==============================
Sprite_Damage.prototype.createCounter = function () {
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(0, 6 * h, 10 * w, h);
sprite.dy = 0;
sprite.x = (5 * w) / 2;
};
//==============================
// ** Create Reflect
//==============================
Sprite_Damage.prototype.createReflection = function () {
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(0, 7 * h, 10 * w, h);
sprite.dy = 0;
sprite.x = (5 * w) / 2;
};
//==============================
// ** CreateChild Sprite
//==============================
Sprite_Damage.prototype.createChildSprite = function () {
var sprite = new Sprite();
sprite.bitmap = this._damageBitmap;
this.setBaseData(sprite);
return sprite;
};
//==============================
// ** set Base Data
//==============================
Sprite_Damage.prototype.setBaseData = function (sprite) {
sprite.anchor.x = 0.5;
sprite.anchor.y = 1;
sprite.y = -40;
sprite.zt = 0;
sprite.ry = sprite.y;
sprite.yf = 0;
sprite.yf2 = 0;
sprite.yf3 = 0;
sprite.ex = false;
this.addChild(sprite);
};
//==============================
// ** createDigits
//==============================
Sprite_Damage.prototype.createDigits = function (baseRow, value) {
var string = Math.abs(value).toString();
var row = baseRow + (value < 0 ? 1 : 0);
var w = this.digitWidth();
var h = this.digitHeight();
for (var i = 0; i < string.length; i++) {
var sprite = this.createChildSprite();
var n = Number(string[i]);
sprite.setFrame(n * w, row * h, w, h);
sprite.x = (i - (string.length - 1) / 2) * w;
sprite.dy = -i;
if (this._zoomEffect) { this.setZoomEffect(sprite, string.length * 2, i) };
};
this._damage = [value, string.length];
};
//==============================
// ** Setup Critical Effect
//==============================
var _mog_sprtdmb_setupCriticalEffect = Sprite_Damage.prototype.setupCriticalEffect;
Sprite_Damage.prototype.setupCriticalEffect = function () {
_mog_sprtdmb_setupCriticalEffect.call(this);
this.createCritical();
};
//==============================
// ** DigiHeight
//==============================
Sprite_Damage.prototype.digitHeight = function () {
return this._damageBitmap ? this._damageBitmap.height / 8 : 0;
};
//==============================
// ** set Zoom Effect
//==============================
Sprite_Damage.prototype.setZoomEffect = function (sprite, d, i) {
if (!d) { d = 0 };
if (!i) { i = 0 };
sprite.scale.x = 2.5;
sprite.scale.y = 2.5;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
sprite.yf = this.digitHeight() / 2;
this._duration += d;
sprite.zt = 5 * i;
};
//==============================
// ** Update Child
//==============================
Sprite_Damage.prototype.updateChild = function (sprite) {
sprite.setBlendColor(this._flashColor);
if (sprite.zt > 0) { sprite.zt -= 1; sprite.opacity = 0 };
if (sprite.zt <= 0) { this.updateDmgSpriteEffect(sprite) };
}
//==============================
// ** Update Dmg Sprite Effect
//==============================
Sprite_Damage.prototype.updateDmgSpriteEffect = function (sprite) {
if (this._animeType === 0) {
this.updateBounceEffect(sprite);
} else { this.updateFlyEffect(sprite) }
if (this._zoomEffect) { this.updateZoomEffect(sprite) };
};
//==============================
// ** Update Fly Effect
//==============================
Sprite_Damage.prototype.updateFlyEffect = function (sprite) {
sprite.yf3 -= 1;
sprite.y = - sprite.yf2 + sprite.yf3;
if (this._duration > 30) {
sprite.opacity += 10
} else { sprite.opacity -= 10 };
};
//==============================
// ** Update Bounce Effect
//==============================
Sprite_Damage.prototype.updateBounceEffect = function (sprite) {
sprite.opacity += 35;
sprite.dy += 0.5;
sprite.ry += sprite.dy;
if (sprite.ry >= 0) {
sprite.ry = 0;
sprite.dy *= -0.6;
};
sprite.y = Math.round(sprite.ry) - sprite.yf - sprite.yf2;
};
//==============================
// ** Update Zoom Effect
//==============================
Sprite_Damage.prototype.updateZoomEffect = function (sprite) {
if (sprite.scale.x > 1.00) { sprite.scale.x -= 0.05 };
sprite.scale.y = sprite.scale.x;
};
//===========================================================================
// ** Sprite Battler
//===========================================================================
//==============================
// ** initMemters
//==============================
var _mog_dmgpopup_sprbat_initMembers = Sprite_Battler.prototype.initMembers;
Sprite_Battler.prototype.initMembers = function () {
_mog_dmgpopup_sprbat_initMembers.call(this);
this._dmgCenter = String(Moghunter.dmgp_center_y) === "true" ? true : false;
};
//===========================================================================
// ** Sprite Actor
//===========================================================================
//==============================
// ** damageOffsetX
//==============================
Sprite_Actor.prototype.damageOffsetX = function () {
return this._battler._dmgOffsetX;
};
//==============================
// ** damageOffsetY
//==============================
Sprite_Actor.prototype.damageOffsetY = function () {
return this._battler._dmgOffsetY;
};
//===========================================================================
// ** Sprite Enemy
//===========================================================================
//==============================
// ** damageOffsetX
//==============================
Sprite_Enemy.prototype.damageOffsetX = function () {
return this._battler._dmgOffsetX;
};
//==============================
// ** damageOffsetY
//==============================
Sprite_Enemy.prototype.damageOffsetY = function () {
if (this._dmgCenter && this.bitmap) { return (-this.bitmap.height / 2) + this._battler._dmgOffsetY + 16; };
return this._battler._dmgOffsetY;
};