-
Notifications
You must be signed in to change notification settings - Fork 6
/
TPB_CastGauge.js
168 lines (150 loc) · 5.5 KB
/
TPB_CastGauge.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
/*:
@target MZ
@plugindesc スキル発動待機時間ゲージ表示プラグイン v1.0.3
@author うなぎおおとろ
@url https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/TPB_CastGauge.js
@param CastGaugeColor1
@type string
@default #ff0000
@desc
スキル発動待機ゲージのメインカラーを指定します。
@param CastGaugeColor2
@type string
@default #ffaaaa
@desc
スキル発動待機ゲージのサブカラーを指定します。
@help
スキル発動待機時間をゲージとして表示するプラグインです。
このプラグインは導入するだけで使用できます。
[ライセンス]
このプラグインは、MITライセンスの条件の下で利用可能です。
[更新履歴]
v1.0.0 新規作成
*/
(() => {
"use strict";
const pluginName = document.currentScript.src.match(/^.*\/(.+)\.js$/)[1];
const params = PluginManager.parameters(pluginName);
const CastGaugeColor1 = params["CastGaugeColor1"];
const CastGaugeColor2 = params["CastGaugeColor2"];
/* Sprite_Gauge */
Sprite_Gauge.prototype.gaugeColor1 = function() {
switch (this._statusType) {
case "hp":
return ColorManager.hpGaugeColor1();
case "mp":
return ColorManager.mpGaugeColor1();
case "tp":
return ColorManager.tpGaugeColor1();
case "time":
return ColorManager.ctGaugeColor1();
case "cast":
return CastGaugeColor1;
default:
return ColorManager.normalColor();
}
};
Sprite_Gauge.prototype.gaugeColor2 = function() {
switch (this._statusType) {
case "hp":
return ColorManager.hpGaugeColor2();
case "mp":
return ColorManager.mpGaugeColor2();
case "tp":
return ColorManager.tpGaugeColor2();
case "time":
return ColorManager.ctGaugeColor2();
case "cast":
return CastGaugeColor2;
default:
return ColorManager.normalColor();
}
};
Sprite_Gauge.prototype.currentValue = function() {
if (this._battler) {
switch (this._statusType) {
case "hp":
return this._battler.hp;
case "mp":
return this._battler.mp;
case "tp":
return this._battler.tp;
case "time":
return this._battler.tpbChargeTime();
case "cast":
return this._battler._tpbCastTime;
}
}
return NaN;
};
Sprite_Gauge.prototype.currentMaxValue = function() {
if (this._battler) {
switch (this._statusType) {
case "hp":
return this._battler.mhp;
case "mp":
return this._battler.mmp;
case "tp":
return this._battler.maxTp();
case "time":
return 1;
case "cast":
return this._battler.tpbRequiredCastTime();
}
}
return NaN;
};
Sprite_Gauge.prototype.gaugeX = function() {
return (this._statusType === "time" || this._statusType === "cast") ? 0 : 30;
};
Sprite_Gauge.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this._duration === 0) {
if (this._battler._tpbState === "casting" && this._statusType === "time" && this.isNeedCast()) {
this._statusType = "cast";
} else if (this._battler._tpbState === "charging" && this._statusType === "cast") {
this._statusType = "time";
}
}
this.updateBitmap();
};
Sprite_Gauge.prototype.updateFlashing = function() {
if (this._statusType === "time" || this._statusType === "cast") {
this._flashingCount++;
if (this._battler.isInputting()) {
if (this._flashingCount % 30 < 15) {
this.setBlendColor(this.flashingColor1());
} else {
this.setBlendColor(this.flashingColor2());
}
} else {
this.setBlendColor([0, 0, 0, 0]);
}
}
};
Sprite_Gauge.prototype.smoothness = function() {
if (this.isNeedCast() && this._battler._tpbState === "casting") return 1;
return (this._statusType === "time" || this._statusType === "cast") ? 5 : 20;
};
Sprite_Gauge.prototype.redraw = function() {
this.bitmap.clear();
const currentValue = this.currentValue();
if (!isNaN(currentValue)) {
this.drawGauge();
if (this._statusType !== "time" && this._statusType !== "cast") {
this.drawLabel();
if (this.isValid()) {
this.drawValue();
}
}
}
};
const _Sprite_Gauge_gaugeRate = Sprite_Gauge.prototype.gaugeRate;
Sprite_Gauge.prototype.gaugeRate = function() {
if (this._statusType === "cast" && this._battler._tpbState === "acting") return 1;
return _Sprite_Gauge_gaugeRate.call(this);
};
Sprite_Gauge.prototype.isNeedCast = function() {
return this._battler.tpbRequiredCastTime() > 0;
}
})();