Skip to content

Instantly share code, notes, and snippets.

@aaaaagold
Last active May 5, 2021 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaaaagold/5edad2ef8dd7771e94293c6b101afe77 to your computer and use it in GitHub Desktop.
Save aaaaagold/5edad2ef8dd7771e94293c6b101afe77 to your computer and use it in GitHub Desktop.
an RMMV plugin
"use strict";
/*:
* @plugindesc 戰鬥時角色新增"等待"指令,使用後atb從一半開始累積
* @author agold404
*
* @help 透過 waitSkillId 設定角色使用"等待"後會使用的技能ID,預設是防禦(ID=2)。
* 若該ID的技能不存在,則不會有"等待"效果,atb將從0開始累積。
* 此插件的值階可在遊戲進行中再多次調整,
* 唯自動產生過的空白技能不因isAutoConfigWaitSkill設定為true以外的字串而刪除。
*
* @param mergeToGuard
* @desc true: 選單不會多出"等待",使用防禦時,atb從一半開始累積 ; 其他值: 依遊戲原本設定
* @default true
*
* @param waitSkillId
* @desc 設定使用"等待"後,會使用的技能ID。若設為空字串或autoConfig為true,則會忽略此項。
* @default 2
*
* @param isAutoConfigWaitSkill
* @desc true: 忽略waitSkillId並使用自動產生的空白技能 (大小寫有區別) ; 其他值: 不自動產生空白技能。 第一次使用"等待"時才會產生。
* @default false
*
* @param autoConfigSkillUseMsg
* @desc 設定使用自動產生的技能會時會在BattleLog中寫出來的文字(message1)。autoConfigNewSkill為true,此項才會有效果。
* @default 等待時機...
*
* @param altCmdName
* @desc 將"等待"字樣換成別的東西
* @default 等待
*/
// 等待
(()=>{ let $aaaa$,$dddd$,$rrrr$,$tttt$;
const key= '_setupATBFromHalfNextTime' ;
const parameters = PluginManager.parameters('waitFromHalfAtbSpeed');
// 產生空白技能
let autoGenWaitSkill;
const getWaitSkillId=()=>{
if(parameters.isAutoConfigWaitSkill!=="true") return parameters.waitSkillId||2;
if(!autoGenWaitSkill){
$dataSkills.push(autoGenWaitSkill={
"id":$dataSkills.length,
"animationId":0,
"damage":{"critical":false,"elementId":0,"formula":"0","type":0,"variance":0},
"description":"do nothing",
"effects":[],
"hitType":0,
"iconIndex":0,
"message1":"",
"message2":"",
"mpCost":0,
"name":"Wait",
"note":"",
"occasion":1,
"repeats":1,
"requiredWtypeId1":0,"requiredWtypeId2":0,
"scope":0,
"speed":0,
"stypeId":0,
"successRate":100,
"tpCost":0,
"tpGain":0,
"meta":{}
});
if($dataSkills[2].targetActions) autoGenWaitSkill.targetActions=[];
if($dataSkills[2].setupActions) autoGenWaitSkill.setupActions=[];
if($dataSkills[2].finishActions) autoGenWaitSkill.finishActions=[];
for(let i in $dataSkills[2]) if(!(i in autoGenWaitSkill)) autoGenWaitSkill[i]=$dataSkills[2][i];
}
autoGenWaitSkill.message1=parameters.autoConfigSkillUseMsg?" "+parameters.autoConfigSkillUseMsg:""
autoGenWaitSkill.name=parameters.altCmdName;
return autoGenWaitSkill.id;
};
// "等待"指令
{
const p=Window_ActorCommand.prototype,k='makeCommandList';
$rrrr$=p[k];
$dddd$=p[k]=function f(){
f.ori.call(this);
f.tbl[0]=parameters.altCmdName;
if(parameters.mergeToGuard!=="true" && this._actor) this.addCommand.apply(this,f.tbl);
}; $dddd$.ori=$rrrr$;
$dddd$.tbl=["等待","wait",1,]; // name,symbol,enabled,ext
}
{
const p=Scene_Battle.prototype , k='createActorCommandWindow' , g='commandGuard';
const logForHalf=function(actor){
if(!this[key]) this[key]=new Map();
const r=this[key].get(actor);
if(r>0) this[key].set(actor,r+1);
else this[key].set(actor,1);
};
$rrrr$=p[k];
$dddd$=p[k]=function f(){
f.ori.call(this);
const w=this._actorCommandWindow;
w.setHandler('wait', this.cmd_wait.bind(this));
}; $dddd$.ori=$rrrr$;
p.cmd_wait=function(){
logForHalf.call(this,this._actorCommandWindow._actor);
BattleManager.inputtingAction().setSkill(getWaitSkillId());
this.selectNextCommand();
};
$rrrr$=p[g];
$dddd$=p[g]=function f(){
if(parameters.mergeToGuard==="true") logForHalf.call(this,this._actorCommandWindow._actor);
f.ori.call(this);
}; $dddd$.ori=$rrrr$;
}
// endTurn時檢查是否在"等待"清單中
{
const p=Game_Battler.prototype;
$rrrr$=p.endTurnAllATB;
$dddd$=p.endTurnAllATB=function f(){
const sc=SceneManager._scene;
const atbsp=this._atbSpeed;
f.ori.call(this);
if(sc){
if(!sc[key]) sc[key]=new Map();
let r=sc[key].get(this);
if(r>0){
--r;
if(r) sc[key].set(this,r);
else sc[key].delete(this);
//this.setATBCharge(atb>>1);
this._atbSpeed=atbsp>>1;
}
}
}; $dddd$.ori=$rrrr$;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment