アクターにHPのような数字を新たに追加するプラグインを作ろうとしています。
Object.defineProperties(Game_BattlerBase.prototype, {…}の部分が関係することは分かりましたが、その中の
hp: { get: function() { return this._hp; }, configurable: true }
のthis._hp部分などの本体部分がどこにあるのかが分かりません。
._hpの本体がどこなのか、もしくはもっと簡単にやりたいことを実現する方法をご教示いただければと思います。
↓現在作ろうとしているプラグインのコードです
コード: 全て選択
//=============================================================================
// K_Fullness.js
//=============================================================================
/*:ja
* @plugindesc ver1.00 満腹、水分、睡眠のゲージを追加。
* @author かいとりせんこう
*
* @param fullness
* @desc 追加ゲージ2つ目
* @default 満腹
*
* @param hydration
* @desc 追加ゲージ2つ目
* @default 水分
*
* @param sleep
* @desc 追加ゲージ3つ目
* @default 睡眠
*
* @param HPIcon
* @desc HPのアイコンインデックス
* @default 84
*
* @param MPIcon
* @desc MPのアイコンインデックス
* @default 78
*
* @param TPIcon
* @desc TPのアイコンインデックス
* @default 77
*
* @param FullnessIcon
* @desc 満腹度のアイコンインデックス
* @default 266
*
* @param HydrationIcon
* @desc 水分のアイコンインデックス
* @default 67
*
* @param SleepIcon
* @desc 睡眠のアイコンインデックス
* @default 8
*
* @param max
* @desc ゲージの最大値
* @default 100
*
* @param TPwrite
* @desc TPを表示するかどうか true or false
* @default true
*
* @param writeIcon
* @desc trueだとアイコン、falseだとテキストになる
* @default true
*
* @help
* 機能:
* ・満腹、水分、睡眠のゲージを追加します(名称をコンフィグで変更可)
* ・メニュー画面で各種ゲージを小さくして表示します
* ・ゲージでテキストの代わりにアイコンを表示します(コンフィグで変更可)
*
*/
(function() {
var parameters = PluginManager.parameters('K_Fullness');
var fuW = String(parameters['fullness']);
var hydW = String(parameters['hydration']);
var slpW = String(parameters['sleep']);
var hpicon = Number(parameters['HPIcon']);
var mpicon = Number(parameters['MPIcon']);
var tpicon = Number(parameters['TPIcon']);
var fulicon = Number(parameters['FullnessIcon']);
var hydicon = Number(parameters['HydrationIcon']);
var slpicon = Number(parameters['SleepIcon']);
var maxparam = Number(parameters['max']);
var tpwrite = String(parameters['TPwrite']);
var writeicon = String(parameters['writeIcon']);
//HP、MP、TPゲージ書き換え
Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
width = width || 186;
var color1 = this.hpGaugeColor1();
var color2 = this.hpGaugeColor2();
this.drawGauge(x, y, width, actor.hpRate(), color1, color2);
this.changeTextColor(this.systemColor());
if(writeicon == 'true'){
this.drawIcon(hpicon,x,y)
}else{
this.drawText(TextManager.hpA, x, y, 44); }
this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
this.hpColor(actor), this.normalColor());
};
Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
width = width || 186;
var color1 = this.mpGaugeColor1();
var color2 = this.mpGaugeColor2();
this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
this.changeTextColor(this.systemColor());
if(writeicon == 'true'){
this.drawIcon(mpicon,x,y)
}else{
this.drawText(TextManager.mpA, x, y, 44);}
this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
this.mpColor(actor), this.normalColor());
};
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
width = width || 96;
var color1 = this.tpGaugeColor1();
var color2 = this.tpGaugeColor2();
this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
this.changeTextColor(this.systemColor());
if(writeicon == 'true'){
this.drawIcon(tpicon,x,y)
}else{
this.drawText(TextManager.tpA, x, y, 44);}
this.changeTextColor(this.tpColor(actor));
this.drawText(actor.tp, x + width - 64, y, 64, 'right');
};
//満腹、水分、睡眠を追加
Object.defineProperties(Game_BattlerBase.prototype, {
// Hit Points
hp: { get: function() { return this._hp; }, configurable: true },
// Magic Points
mp: { get: function() { return this._mp; }, configurable: true },
// Tactical Points
tp: { get: function() { return this._tp; }, configurable: true },
// Maximum Hit Points
mhp: { get: function() { return this.param(0); }, configurable: true },
// Maximum Magic Points
mmp: { get: function() { return this.param(1); }, configurable: true },
// ATtacK power
atk: { get: function() { return this.param(2); }, configurable: true },
// DEFense power
def: { get: function() { return this.param(3); }, configurable: true },
// Magic ATtack power
mat: { get: function() { return this.param(4); }, configurable: true },
// Magic DeFense power
mdf: { get: function() { return this.param(5); }, configurable: true },
// AGIlity
agi: { get: function() { return this.param(6); }, configurable: true },
// LUcK
luk: { get: function() { return this.param(7); }, configurable: true },
// HIT rate
hit: { get: function() { return this.xparam(0); }, configurable: true },
// EVAsion rate
eva: { get: function() { return this.xparam(1); }, configurable: true },
// CRItical rate
cri: { get: function() { return this.xparam(2); }, configurable: true },
// Critical EVasion rate
cev: { get: function() { return this.xparam(3); }, configurable: true },
// Magic EVasion rate
mev: { get: function() { return this.xparam(4); }, configurable: true },
// Magic ReFlection rate
mrf: { get: function() { return this.xparam(5); }, configurable: true },
// CouNTer attack rate
cnt: { get: function() { return this.xparam(6); }, configurable: true },
// Hp ReGeneration rate
hrg: { get: function() { return this.xparam(7); }, configurable: true },
// Mp ReGeneration rate
mrg: { get: function() { return this.xparam(8); }, configurable: true },
// Tp ReGeneration rate
trg: { get: function() { return this.xparam(9); }, configurable: true },
// TarGet Rate
tgr: { get: function() { return this.sparam(0); }, configurable: true },
// GuaRD effect rate
grd: { get: function() { return this.sparam(1); }, configurable: true },
// RECovery effect rate
rec: { get: function() { return this.sparam(2); }, configurable: true },
// PHArmacology
pha: { get: function() { return this.sparam(3); }, configurable: true },
// Mp Cost Rate
mcr: { get: function() { return this.sparam(4); }, configurable: true },
// Tp Charge Rate
tcr: { get: function() { return this.sparam(5); }, configurable: true },
// Physical Damage Rate
pdr: { get: function() { return this.sparam(6); }, configurable: true },
// Magical Damage Rate
mdr: { get: function() { return this.sparam(7); }, configurable: true },
// Floor Damage Rate
fdr: { get: function() { return this.sparam(8); }, configurable: true },
// EXperience Rate
exr: { get: function() { return this.sparam(9); }, configurable: true },
//↓問題の部分 今はとりあえずthis._hpにしてる
ful: { get: function() { return this._hp; }, configurable: true },
hyd: { get: function() { return this._hp; }, configurable: true },
slp: { get: function() { return this._hp; }, configurable: true },
//↑問題の部分
});
Game_BattlerBase.prototype.fulRate = function() {
return this.ful / maxparam;
};
Game_BattlerBase.prototype.hydRate = function() {
return this.hyd / maxparam;
};
Game_BattlerBase.prototype.slpRate = function() {
return this.slp / maxparam;
};
Window_Base.prototype.drawActorFullness = function(actor, x, y, width) {
width = width || 96;
var color1 = this.hpGaugeColor1();
var color2 = this.hpGaugeColor2();
this.drawGauge(x, y, width, actor.fulRate(), color1, color2);
this.changeTextColor(this.systemColor());
if(writeicon == 'true'){
this.drawIcon(fulicon,x,y);
}else{
this.drawText(fuW, x, y, 44);}
this.drawCurrentAndMax(actor.ful, maxparam, x, y, width,
this.hpColor(actor), this.normalColor());
};
Window_Base.prototype.drawActorHydration = function(actor, x, y, width) {
width = width || 96;
var color1 = this.mpGaugeColor1();
var color2 = this.mpGaugeColor2();
this.drawGauge(x, y, width, actor.hydRate(), color1, color2);
this.changeTextColor(this.systemColor());
if(writeicon == 'true'){
this.drawIcon(hydicon,x,y);
}else{
this.drawText(hydW, x, y, 44);}
this.drawCurrentAndMax(actor.hyd, maxparam, x, y, width,
this.mpColor(actor), this.normalColor());
};
Window_Base.prototype.drawActorSleep = function(actor, x, y, width) {
width = width || 96;
var color1 = this.tpGaugeColor1();
var color2 = this.tpGaugeColor2();
this.drawGauge(x, y, width, actor.slpRate(), color1, color2);
this.changeTextColor(this.systemColor());
if(writeicon == 'true'){
this.drawIcon(slpicon,x,y);
}else{
this.drawText(slpW, x, y, 44);}
this.drawCurrentAndMax(actor.slp, maxparam, x, y, width,
this.tpColor(actor), this.normalColor());
};
//メニュー書き換え
Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
var lineHeight = this.lineHeight();
var x2 = x + 180;
var width2 = Math.min(200, width - 180 - this.textPadding())/2;
var x3 = x2 + width2 + 5;
this.drawActorName(actor, x, y);
this.drawActorLevel(actor, x, y + lineHeight * 1);
this.drawActorIcons(actor, x, y + lineHeight * 2);
this.drawActorClass(actor, x2, y - lineHeight/2 * 1);
this.drawActorHp(actor, x2, y + lineHeight/2 * 1, width2);
this.drawActorMp(actor, x2, y + lineHeight/2 * 3, width2);
if(tpwrite == 'true'){
this.drawActorTp(actor, x2, y + lineHeight/2 * 5, width2);
}
this.drawActorFullness(actor, x3, y + lineHeight/2 * 1, width2);
this.drawActorHydration(actor, x3, y + lineHeight/2 * 3, width2);
this.drawActorSleep(actor, x3, y + lineHeight/2 * 5, width2);
};
})();
今のところエラーなどは出ません