forked from triacontane/RPGMakerMV
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCharacterPopupDamage.js
714 lines (651 loc) · 29 KB
/
CharacterPopupDamage.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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
//=============================================================================
// CharacterPopupDamage.js
// ----------------------------------------------------------------------------
// (C) 2016 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.6.1 2019/04/20 ダメージが0だった場合の表記を「MISS」から「0」に変更
// 1.6.0 2018/11/11 プラグインの型指定機能に対応
// ポップアップ効果音を消音できるスイッチを追加
// 1.5.1 2017/11/10 コピペミスによる誤記を修正
// 1.5.0 2017/04/23 ポップアップ時にキャラクターをフラッシュさせる機能を追加
// 1.4.0 2017/03/03 ピクチャより前面にポップアップできる設定を追加
// 回転がない場合でも拡大率を自由に変更できるよう修正
// 1.3.0 2017/01/23 スリップダメージのポップアップに対応
// 対応するフォロワーのポップアップを表示する機能を追加
// 1.2.0 2016/12/31 ポップアップの色調設定機能を追加
// ポップアップの表示方法を詳細指定できる機能を追加
// 1.1.1 2016/09/15 最新の修正で自動ポップアップの設定が手動に影響していた問題を修正
// 1.1.0 2016/09/14 MPダメージ用に専用効果音を指定できる機能を追加
// HP、MP、TP、増加、減少の条件で個別に出力可否を設定できる機能を追加
// 1.0.3 2016/09/10 VE_BasicModule.jsとの競合を解消
// 1.0.2 2016/04/17 ポップアップ無効化のプラグインコマンドが機能していなかった問題を修正
// 1.0.1 2016/04/10 HPの増減との連動で増やすと減らすが逆に解釈されていたのを修正
// 1.0.0 2016/04/09 初版
// ----------------------------------------------------------------------------
// [Blog] : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================
/*:
* @plugindesc キャラクターのダメージポッププラグイン
* @author トリアコンタン
*
* @param 効果音演奏
* @desc 状況に応じたシステム効果音を自動演奏します。(ON/OFF)
* @default true
* @type boolean
*
* @param 消音スイッチID
* @desc 指定したIDのスイッチがONになっているとき、システム効果音が自動演奏されなくなります。
* @default 0
* @type switch
*
* @param X座標補正
* @desc ポップアップ位置のX座標を補正します。
* @default 0
*
* @param Y座標補正
* @desc ポップアップ位置のY座標を補正します。
* @default 0
*
* @param HP自動ポップアップ
* @desc HPの増減を自動ポップアップの対象にします。(ON/OFF)
* @default true
* @type boolean
*
* @param MP自動ポップアップ
* @desc MPの増減を自動ポップアップの対象にします。(ON/OFF)
* @default true
* @type boolean
*
* @param TP自動ポップアップ
* @desc TPの増減を自動ポップアップの対象にします。(ON/OFF)
* @default true
* @type boolean
*
* @param 増加自動ポップアップ
* @desc パラメータの増加を自動ポップアップの対象にします。(ON/OFF)
* @default true
* @type boolean
*
* @param 減少自動ポップアップ
* @desc パラメータの減少を自動ポップアップの対象にします。(ON/OFF)
* @default true
* @type boolean
*
* @param MPダメージ音
* @desc MPダメージ時の効果音ファイル名を別途指定(audio/se)します。何も指定しないとHPと同じになります。
* @default
*
* @param 回転
* @desc 数字の回転運動を有効にします。
* @default true
* @type boolean
*
* @param X方向半径
* @desc 数字を回転させる場合のX方向の半径です。
* @default 40
*
* @param Y方向半径
* @desc 数字を回転させる場合のY方向の半径です。
* @default 40
*
* @param 回転速度
* @desc 数字を回転させる場合の速度です。
* @default 60
*
* @param 拡大率
* @desc 初期状態の拡大率です。
* @default 100
*
* @param 拡大率変化値
* @desc 1フレームごとの拡大率の変化値です。
* @default -10
*
* @param 最前面表示
* @desc ポップアップをピクチャより前面に表示します。
* @default false
* @type boolean
*
* @help マップ画面でイベントやプレイヤーに数字をポップアップさせる機能を提供します。
* マップ上でのダメージや回復の演出に利用できます。演出は戦闘時のものと同一です。
* 指定する値をマイナスにすると回復扱いとなり色が変わります。
* また、クリティカルにすると数字の色が一瞬、赤くなります。
*
* また「HPの増減」等のイベント実行時に自動で変化量をポップアップする機能や、
* ダメージ床を通過した際に自動でポップアップする機能も用意されています。
* パラメータにより、HPのみや増加のみといった条件指定もできます。
*
* プラグインコマンド詳細
* イベントコマンド「プラグインコマンド」から実行。
* (パラメータの間は半角スペースで区切る)
*
* ・CPD_DAMAGE or ポップアップダメージ [キャラクターID] [ダメージ値] [反転]
* キャラクターを指定してダメージをポップアップします。
* キャラクターの指定は以下の通りです。
* -1 : プレイヤー
* 0 : 実行中のイベント
* 1.. : 指定したIDのイベント
*
* 反転を有効にすると、ポップアップの回転方向が逆になります。
* (パラメータの「回転」を有効にしている場合)
*
* CPD_DAMAGE 5 -300 ON
* ポップアップダメージ 0 \v[1] OFF
*
* ・CPD_CRITICAL or ポップアップクリティカル
* キャラクターを指定してダメージをクリティカル扱いでポップアップします。
*
* CPD_CRITICAL -1 100 ON
* ポップアップクリティカル 3 \v[1] OFF
*
* ・CPD_MP_DAMAGE or ポップアップMPダメージ
* キャラクターを指定してMPダメージをポップアップします。
*
* CPD_MP_DAMAGE 5 -300 ON
* ポップアップMPダメージ 0 \v[1] OFF
*
* ・CPD_MP_CRITICAL or ポップアップMPクリティカル
* キャラクターを指定してMPダメージをクリティカル扱いでポップアップします。
*
* CPD_MP_CRITICAL -1 100 ON
* ポップアップMPクリティカル 3 \v[1] OFF
*
* ・CPD_MISS or ポップアップミス
* キャラクターを指定してmissをポップアップします。
*
* CPD_MISS -1 ON
* ポップアップミス 3 OFF
*
* ・CPD_INVALID or ポップアップ無効化
* 自動ポップアップを無効にします。
* 有効になっているとイベントコマンド「HPの増減」「MPの増減」「TPの増減」
* およびダメージ床によるダメージが自動でポップアップします。
* 初期状態では有効です。
*
* ・CPD_VALID or ポップアップ有効化
* 自動ポップアップを再度有効にします。
*
* ・CPD_SETTING_TONE or ポップアップ設定_色調 [赤] [緑] [青] [グレー]
* ポップアップ画像の色調を変更できます。色調の設定値を順番に指定してください。
*
* CPD_SETTING_TONE 255 0 0 255
* ポップアップ設定_色調 -255 -255 -255 0
*
* ・CPD_SETTING_FLASH or ポップアップ設定_フラッシュ [赤] [緑] [青] [強さ]
* ポップアップ時にキャラクターをフラッシュします。
* フラッシュするのはダメージを受けた場合のみです。
*
* CPD_SETTING_FLASH 255 0 0 255
* ポップアップ設定_フラッシュ 255 0 0 255
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
(function() {
'use strict';
var pluginName = 'CharacterPopupDamage';
var settings = {
/* MPダメージ専用効果音(ファイル名はパラメータで指定) */
mpDamageSe: {
volume: 90,
pitch : 100,
pan : 0
}
};
var getCommandName = function(command) {
return (command || '').toUpperCase();
};
var getParamBoolean = function(paramNames) {
var value = getParamOther(paramNames);
return (value || '').toUpperCase() === 'ON' || (value || '').toUpperCase() === 'TRUE';
};
var getParamNumber = function(paramNames, min, max) {
var value = getParamOther(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(value, 10) || 0).clamp(min, max);
};
var getParamString = function(paramNames) {
var value = getParamOther(paramNames);
return value === null ? '' : value;
};
var getParamOther = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i < paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames[i]];
if (name) return name;
}
return null;
};
var getArgNumber = function(arg, min, max) {
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(convertEscapeCharactersAndEval(arg, true), 10) || 0).clamp(min, max);
};
var getArgBoolean = function(arg) {
return (arg || '').toUpperCase() === 'ON';
};
var convertEscapeCharactersAndEval = function(text, evalFlg) {
if (text === null || text === undefined) text = '';
var window = SceneManager._scene._windowLayer.children[0];
if (window) {
var result = window.convertEscapeCharacters(text);
return evalFlg ? eval(result) : result;
} else {
return text;
}
};
//=============================================================================
// パラメータの取得と整形
//=============================================================================
var paramPlaySe = getParamBoolean(['PlaySe', '効果音演奏']);
var paramSuppressSwitchId = getParamNumber(['SuppressSwitchId', '消音スイッチID'], 0);
var paramOffsetX = getParamNumber(['OffsetX', 'X座標補正']);
var paramOffsetY = getParamNumber(['OffsetY', 'Y座標補正']);
var paramTpAutoPop = getParamBoolean(['TPAutoPop', 'TP自動ポップアップ']);
var paramMpAutoPop = getParamBoolean(['MPAutoPop', 'MP自動ポップアップ']);
var paramHpAutoPop = getParamBoolean(['HPAutoPop', 'HP自動ポップアップ']);
var paramIncreaseAutoPop = getParamBoolean(['IncreaseAutoPop', '増加自動ポップアップ']);
var paramDecreaseAutoPop = getParamBoolean(['DecreaseAutoPop', '減少自動ポップアップ']);
var paramMpDamageSe = getParamString(['MPDamageSe', 'MPダメージ音']);
var paramRotation = getParamBoolean(['Rotation', '回転']);
var paramRadiusX = getParamNumber(['RadiusX', 'X方向半径']);
var paramRadiusY = getParamNumber(['RadiusY', 'Y方向半径']);
var paramRotateSpeed = getParamNumber(['RotateSpeed', '回転速度']);
var paramScale = getParamNumber(['Scale', '拡大率']);
var paramScaleDelta = getParamNumber(['ScaleDelta', '拡大率変化値']);
var paramOnTop = getParamBoolean(['OnTop', '最前面表示']);
//=============================================================================
// Game_Interpreter
// プラグインコマンドを追加定義します。
//=============================================================================
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.apply(this, arguments);
this.pluginCommandCharacterPopupDamage(command, args);
};
Game_Interpreter.prototype.pluginCommandCharacterPopupDamage = function(command, args) {
var popupArgs = [];
switch (getCommandName(command)) {
case 'CPD_DAMAGE' :
case 'ポップアップダメージ':
popupArgs = [getArgNumber(args[1]), false, getArgBoolean(args[2])];
this.callCharacterPopup(args, 'popupDamage', popupArgs);
break;
case 'CPD_CRITICAL' :
case 'ポップアップクリティカル':
popupArgs = [getArgNumber(args[1]), true, getArgBoolean(args[2])];
this.callCharacterPopup(args, 'popupDamage', popupArgs);
break;
case 'CPD_MP_DAMAGE' :
case 'ポップアップMPダメージ':
popupArgs = [getArgNumber(args[1]), false, getArgBoolean(args[2])];
this.callCharacterPopup(args, 'popupMpDamage', popupArgs);
break;
case 'CPD_MP_CRITICAL' :
case 'ポップアップMPクリティカル':
popupArgs = [getArgNumber(args[1]), true, getArgBoolean(args[2])];
this.callCharacterPopup(args, 'popupMpDamage', popupArgs);
break;
case 'CPD_MISS' :
case 'ポップアップミス':
popupArgs = [getArgBoolean(args[1])];
this.callCharacterPopup(args, 'popupMiss', popupArgs);
break;
case 'CPD_VALID' :
case 'ポップアップ有効化':
$gameSystem.setSuppressAutoPopup(false);
break;
case 'CPD_INVALID' :
case 'ポップアップ無効化':
$gameSystem.setSuppressAutoPopup(true);
break;
case 'CPD_SETTING_TONE' :
case 'ポップアップ設定_色調':
var red = getArgNumber(args[0]);
var green = getArgNumber(args[1]);
var blue = getArgNumber(args[2]);
var gray = getArgNumber(args[3]);
$gameSystem.setPopupDamageTone([red, green, blue, gray]);
break;
case 'CPD_SETTING_FLASH' :
case 'ポップアップ設定_フラッシュ':
var flashRed = getArgNumber(args[0], 0);
var flashGreen = getArgNumber(args[1], 0);
var flashBlue = getArgNumber(args[2], 0);
var alpha = getArgNumber(args[3], 0) || 255;
$gameSystem.setPopupDamageFlash([flashRed, flashGreen, flashBlue, alpha]);
break;
}
};
var _Game_Interpreter_command311 = Game_Interpreter.prototype.command311;
Game_Interpreter.prototype.command311 = function() {
var value = -this.operateValue(this._params[2], this._params[3], this._params[4]);
this.iterateActorEx(this._params[0], this._params[1], function(actor) {
actor.popupDamage(value);
}.bind(this));
return _Game_Interpreter_command311.apply(this, arguments);
};
var _Game_Interpreter_command312 = Game_Interpreter.prototype.command312;
Game_Interpreter.prototype.command312 = function() {
var value = -this.operateValue(this._params[2], this._params[3], this._params[4]);
this.iterateActorEx(this._params[0], this._params[1], function(actor) {
actor.popupMpDamage(value);
}.bind(this));
return _Game_Interpreter_command312.apply(this, arguments);
};
var _Game_Interpreter_command326 = Game_Interpreter.prototype.command326;
Game_Interpreter.prototype.command326 = function() {
var value = -this.operateValue(this._params[2], this._params[3], this._params[4]);
this.iterateActorEx(this._params[0], this._params[1], function(actor) {
actor.popupTpDamage(value);
}.bind(this));
return _Game_Interpreter_command326.apply(this, arguments);
};
Game_Interpreter.prototype.callCharacterPopup = function(args, methodName, extend) {
var character = this.character(getArgNumber(args[0], -1));
if (character) character[methodName].apply(character, extend);
};
//=============================================================================
// Game_Actor
// ダメージ床によるポップアップを処理します。
//=============================================================================
var _Game_Actor_executeFloorDamage = Game_Actor.prototype.executeFloorDamage;
Game_Actor.prototype.executeFloorDamage = function() {
this.popupMapDamage(_Game_Actor_executeFloorDamage);
};
var _Game_Actor_turnEndOnMap = Game_Actor.prototype.turnEndOnMap;
Game_Actor.prototype.turnEndOnMap = function() {
this.popupMapDamage(_Game_Actor_turnEndOnMap);
};
Game_Actor.prototype.popupMapDamage = function(callBackFunc) {
var prevHp = this.hp;
var prevMp = this.mp;
var prevTp = this.tp;
callBackFunc.apply(this);
var character = this.getCharacterObject();
if (!character) return;
var hpDamage = prevHp - this.hp;
if (hpDamage !== 0 && $gameSystem.isNeedAutoHpPopup(hpDamage)) character.popupDamage(hpDamage, false);
var mpDamage = prevMp - this.mp;
if (mpDamage !== 0 && $gameSystem.isNeedAutoMpPopup(mpDamage)) character.popupMpDamage(mpDamage, false);
var tpDamage = prevTp - this.tp;
if (tpDamage !== 0 && $gameSystem.isNeedAutoTpPopup(tpDamage)) character.popupDamage(tpDamage, false);
};
Game_Actor.prototype.popupDamage = function(value) {
var character = this.getCharacterObject();
if (!character) return;
if (value !== 0 && $gameSystem.isNeedAutoHpPopup(value)) {
character.popupDamage(value, false);
}
};
Game_Actor.prototype.popupMpDamage = function(value) {
var character = this.getCharacterObject();
if (!character) return;
if (value !== 0 && $gameSystem.isNeedAutoMpPopup(value)) {
character.popupMpDamage(value, false);
}
};
Game_Actor.prototype.popupTpDamage = function(value) {
var character = this.getCharacterObject();
if (!character) return;
if (value !== 0 && $gameSystem.isNeedAutoTpPopup(value)) {
character.popupDamage(value, false);
}
};
Game_Actor.prototype.getCharacterObject = function() {
var index = $gameParty.battleMembers().indexOf(this);
var result;
switch (index) {
case -1:
result = null;
break;
case 0:
result = $gamePlayer;
break;
default:
var followers = $gamePlayer.followers();
result = followers.isVisible() ? followers.follower(index - 1) : null;
}
return result;
};
//=============================================================================
// Game_System
// オートポップアップの有効フラグを追加定義します。
//=============================================================================
var _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_Game_System_initialize.apply(this, arguments);
this._suppressAutoPopup = false;
this._popupDamageTone = null;
this._popupDamageFlash = null;
};
Game_System.prototype.setSuppressAutoPopup = function(value) {
this._suppressAutoPopup = !!value;
};
Game_System.prototype.isSuppressAutoPopup = function() {
return this._suppressAutoPopup;
};
Game_System.prototype.isNeedAutoHpPopup = function(value) {
return paramHpAutoPop && this.isNeedAutoPopup(value);
};
Game_System.prototype.isNeedAutoMpPopup = function(value) {
return paramMpAutoPop && this.isNeedAutoPopup(value);
};
Game_System.prototype.isNeedAutoTpPopup = function(value) {
return paramTpAutoPop && this.isNeedAutoPopup(value);
};
Game_System.prototype.isNeedAutoPopup = function(value) {
return !$gameSystem.isSuppressAutoPopup() &&
((paramIncreaseAutoPop && value < 0) || (paramDecreaseAutoPop && value > 0));
};
Game_System.prototype.getPopupDamageTone = function() {
return this._popupDamageTone;
};
Game_System.prototype.setPopupDamageTone = function(value) {
this._popupDamageTone = value;
};
Game_System.prototype.getPopupDamageFlash = function() {
return this._popupDamageFlash;
};
Game_System.prototype.setPopupDamageFlash = function(value) {
this._popupDamageFlash = value;
};
//=============================================================================
// Game_CharacterBase
// ダメージ情報を保持します。
//=============================================================================
Game_CharacterBase.prototype.popupDamage = function(value, critical, mirror) {
this.startDamagePopup(value, critical, false, mirror);
};
Game_CharacterBase.prototype.popupMpDamage = function(value, critical, mirror) {
this.startDamagePopup(value, critical, true, mirror);
};
Game_CharacterBase.prototype.popupMiss = function(mirror) {
this.startDamagePopup(null, false, mirror);
};
Game_CharacterBase.prototype.isDamagePopupRequested = function() {
return this._damagePopup;
};
Game_CharacterBase.prototype.clearDamagePopup = function() {
if (!this._damageInfo || this._damageInfo.length === 0) {
this._damagePopup = false;
}
};
Game_CharacterBase.prototype.startDamagePopup = function(value, critical, mpFlg, mirror) {
this._damagePopup = true;
if (!this._damageInfo) this._damageInfo = [];
var damageInfo = {value: value, critical: critical, mpFlg: mpFlg, mirror: mirror};
if (this.isPlayPopupSe()) {
this.playPopupSe(damageInfo);
}
this._damageInfo.push(damageInfo);
};
Game_CharacterBase.prototype.playPopupSe = function(damageInfo) {
if (damageInfo.value === null) {
SoundManager.playMiss();
} else if (damageInfo.value < 0) {
SoundManager.playRecovery();
} else if (damageInfo.mpFlg && paramMpDamageSe) {
settings.mpDamageSe.name = paramMpDamageSe;
AudioManager.playStaticSe(settings.mpDamageSe);
} else if (this === $gamePlayer) {
SoundManager.playActorDamage();
} else {
SoundManager.playEnemyDamage();
}
};
Game_CharacterBase.prototype.shiftDamageInfo = function() {
return this._damageInfo ? this._damageInfo.shift() : null;
};
Game_CharacterBase.prototype.isPlayPopupSe = function() {
return paramPlaySe && !$gameSwitches.value(paramSuppressSwitchId)
};
//=============================================================================
// Sprite_Character
// ダメージをポップアップします。
//=============================================================================
var _Sprite_Character_update = Sprite_Character.prototype.update;
Sprite_Character.prototype.update = function() {
_Sprite_Character_update.apply(this, arguments);
this.updateDamagePopup();
};
Sprite_Character.prototype.updateDamagePopup = function() {
this.setupDamagePopup();
if (this._damages && this._damages.length > 0) {
for (var i = 0; i < this._damages.length; i++) {
this._damages[i].update();
}
if (!this._damages[0].isPlaying()) {
this.getPopupParent().removeChild(this._damages[0]);
this._damages.shift();
}
}
if (this._popupFlash) {
this.updateDamagePopupFlash();
}
};
Sprite_Character.prototype.updateDamagePopupFlash = function() {
this.setBlendColor(this._popupFlash);
this._popupFlash[3] -= this._popupFlashSpeed;
if (this._popupFlash[3] <= 0) {
this._popupFlash = null;
this._popupFlashSpeed = 0;
}
};
Sprite_Character.prototype.setupDamagePopup = function() {
if (!this._character.isDamagePopupRequested()) return;
var sprite = new Sprite_CharacterDamage();
sprite.x = this.x + this.damageOffsetX();
sprite.y = this.y + this.damageOffsetY();
if (!sprite.z) sprite.z = 9;
sprite.setupCharacter(this._character);
if (!this._damages) this._damages = [];
this._damages.push(sprite);
this.getPopupParent().addChild(sprite);
this._character.clearDamagePopup();
if (!sprite.isMiss() && !sprite.isRecover()) {
this.setupDamagePopupFlash();
}
};
Sprite_Character.prototype.setupDamagePopupFlash = function() {
var flashColor = $gameSystem.getPopupDamageFlash();
if (!flashColor) return;
this._popupFlash = flashColor.clone();
this._popupFlashSpeed = Math.floor(this._popupFlash[3] / 30);
this.updateDamagePopupFlash();
};
Sprite_Character.prototype.damageOffsetX = function() {
return paramOffsetX;
};
Sprite_Character.prototype.damageOffsetY = function() {
return paramOffsetY;
};
Sprite_Character.prototype.getPopupParent = function() {
return paramOnTop ? this.parent.parent.parent : this.parent;
};
//=============================================================================
// Sprite_CharacterDamage
// ダメージ情報を受け取ってセットアップします。
//=============================================================================
function Sprite_CharacterDamage() {
this.initialize.apply(this, arguments);
}
Sprite_CharacterDamage.prototype = Object.create(Sprite_Damage.prototype);
Sprite_CharacterDamage.prototype.constructor = Sprite_CharacterDamage;
Sprite_CharacterDamage.prototype.setupCharacter = function(character) {
var damageInfo = character.shiftDamageInfo();
this._toneColor = $gameSystem.getPopupDamageTone();
this._mirror = damageInfo.mirror;
this._damageInfo = damageInfo;
this._digit = 0;
if (this.isMiss()) {
this.createMissForCharacter();
} else {
this.createDigits(damageInfo.mpFlg ? 2 : 0, damageInfo.value);
}
if (damageInfo.critical) {
this.setupCriticalEffect();
}
};
Sprite_CharacterDamage.prototype.isMiss = function() {
return this._damageInfo.value === null;
};
Sprite_CharacterDamage.prototype.isRecover = function() {
return this._damageInfo.value < 0;
};
Sprite_CharacterDamage.prototype.createMissForCharacter = function() {
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(0, 4 * h, 4 * w, h);
sprite.dy = 0;
sprite.x = w / 2;
sprite.digit++;
this._digit++;
};
Sprite_CharacterDamage.prototype.createChildSprite = function() {
var sprite = Sprite_Damage.prototype.createChildSprite.apply(this, arguments);
sprite.frame = 0;
sprite.digit = this._digit++;
if (this._toneColor) sprite.setColorTone(this._toneColor);
return sprite;
};
Sprite_CharacterDamage.prototype.updateChild = function(sprite) {
if (paramRotation) {
this.updateChildRotation(sprite);
sprite.setBlendColor(this._flashColor);
} else {
Sprite_Damage.prototype.updateChild.apply(this, arguments);
sprite.x = 0;
}
if (paramScale) {
this.updateChildScale(sprite);
}
sprite.frame++;
};
Sprite_CharacterDamage.prototype.updateChildRotation = function(sprite) {
var frame = sprite.frame;
var speed = frame / 3600 * paramRotateSpeed;
sprite.rx = paramRadiusX * (Math.cos(speed) - 1);
sprite.ry = -paramRadiusY * Math.sin(speed);
if (this._mirror) {
sprite.rx *= -1;
}
sprite.x = Math.round(sprite.rx);
sprite.y = Math.round(sprite.ry);
};
Sprite_CharacterDamage.prototype.updateChildScale = function(sprite) {
var frame = sprite.frame;
var scale = (paramScale + frame * paramScaleDelta / 10) / 100;
sprite.scale.x = scale;
sprite.scale.y = scale;
sprite.x += (sprite.digit - (this._digit - 1) / 2) * (this.digitWidth() * scale);
};
})();