setActor就是設定actor給某window,用來顯示actor的各項參數,也可用來針對某些actor做變化。
步驟:
(1)在Scene裡面加入這段:
Scene_Status.prototype.refreshActor = function() {var actor = this.actor();// 場景裡create window的名字this._statusWindow.setActor(actor);};
(2)在Window裡面加入這段:
Window_Status.prototype.setActor = function(actor) {if (this._actor !== actor) {this._actor = actor;this.refresh();}};
(3)寫一個函式專門去叫參數:
視窗名稱.prototype.函式名稱 = function() {
var actor = this._actor;if (actor) {
console.log( 'actor=' + actor);console.log( 'actor.hp=' +actor.hp);console.log( 'actor.actorId=' +actor.actorId() );console.log( 'actor.actorId actor 是否在隊伍裡=' + $gameParty.members().contains(actor));
}
};
if很重要,別刪了,會報錯。
這樣在Window_Status裡面就可以叫到actor的參數了,會以this._actor為名。
預設的status還有加上這個以下藍字:
Window_Status.prototype.initialize = function() {var width = 480;var height = 550;Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);this._actor = null;this.refresh();};
既然是原本就有的東西,應該就是有需要吧。
測試:
寫一個新函式,裡面寫
var actor = this._actor;console.log( 'actor=' + actor);
有回傳 'actor='[object Object] 就是成功了,成功後就能來使用以下的actor屬性。
也可用drawText( actor.屬性 ) 直接顯示內容。
以下不完整的整理:
actor.hp
actor.mhp
actor.mp
actor.mhp
actor.tp
actor.mtp
actor.level
//角色ID
actor.actorId()
//角色名稱
actor.name()
//角色職業
actor.currentClass().name
//角色暱稱
actor.nickname()
//現在exp
actor.currentExp()
//升級需求exp
actor.nextRequiredExp()
//畫腳色的臉
this.drawActorFace(this._actor, x, y)
//資料庫內第一個屬性名稱,預設為:攻擊
TextManager.param(2)
//資料庫內第一個屬性值,預設為:攻擊
this._actor.param(2)
//資料庫內第二個屬性名稱,預設為:防禦
TextManager.param(3)
//資料庫內第二個屬性值,預設為:防禦
this._actor.param(3)
//資料庫內第三個屬性名稱,預設為:魔攻
TextManager.param(4)
//資料庫內第三個屬性值,預設為:魔攻
this._actor.param(4)
//資料庫內第四個屬性名稱,預設為:魔防
TextManager.param(5)
//資料庫內第四個屬性值,預設為:魔防
this._actor.param(5)
//資料庫內第五個屬性名稱,預設為:敏捷
TextManager.param(6)
//資料庫內第五個屬性值,預設為:敏捷
this._actor.param(6)
//資料庫內第六個屬性名稱,預設為:運氣
TextManager.param(7)
//資料庫內第六個屬性值,預設為:運氣
this._actor.param(7)
//角色介紹
this._actor.profile()
//命中
actor.hit
//迴避
actor.eva
//爆擊
actor.cri
//爆擊迴避
actor.cev
//魔法迴避
actor.mev
//魔法反射
actor.mrf
//反擊
actor.cnt
//HP再生
actor.hrg
//MP再生
actor.mrg
//TP再生
actor.trg
//目標率
actor.tgr
//防護效果
actor.grd
//藥物效果
actor.pha
//MP消耗率
actor.mcr
//TP回復率
actor.tcr
//物理傷害
actor.pdr
//魔法傷害
actor.mdr
//地面傷害
actor.fdr
//經驗值率
actor.exr
//不明
actor.rec
現在值跟最大值對齊老是歪掉嗎?可以用這個函式:
this.drawCurrentAndMax((current, max, x, y,width, color1, color2)
YEP改寫過的經驗值顯示,可複製貼上到Window_Base_plus.js自己用:
Window_Base.prototype.drawExpInfo = function(x, y) {
var lineHeight = this.lineHeight();var expTotal = TextManager.expTotal.format(TextManager.exp);var expNext = TextManager.expNext.format(TextManager.level);var value1 = this._actor.currentExp();var value2 = this._actor.nextRequiredExp();if (this._actor.isMaxLevel()) {value1 = '-------';value2 = '-------';}this.changeTextColor(this.systemColor());this.drawText(expTotal, x, y + lineHeight * 0, 270);this.drawText(expNext, x, y + lineHeight * 2, 270);this.resetTextColor();this.drawText(value1, x, y + lineHeight * 1, 270, 'right');this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
會變這樣:};