//=============================================================================
// RPG Maker MZ - TriQuestion
//=============================================================================
/*:
* @target MZ
* @plugindesc TriQuestion
* @author Errke
*
* @help TriQuestion.js
* For Three Question.
*
*
*/
(() => {
//第一个问题的解决方法 和 第三个技能解决方法
Game_Action.prototype.apply = function(target) {
const result = target.result();
this.subject().clearResult();
result.clear();
result.used = this.testApply(target);
result.missed = result.used && Math.random() >= this.itemHit(target);
result.evaded = !result.missed && Math.random() < this.itemEva(target);
result.physical = this.isPhysical();
result.drain = this.isDrain();
//修改命中条件,只要是备注里有<bimi>,必定命中。
if (result.isHit() || (this.subject().isActor() && $dataActors[this.subject()._actorId].meta.bimi) ){
result.evaded = false;
if (this.item().damage.type > 0) {
result.critical = Math.random() < this.itemCri(target);
const value = this.makeDamageValue(target, result.critical);
this.executeDamage(target, value);
}
for (const effect of this.item().effects) {
this.applyItemEffect(target, effect);
}
this.applyItemUserEffect(target);
//如果没命中的情况下,使用这个技能备注里<skid>后的技能。
}else if (!result.isHit() && $dataSkills[this.item().id].meta.skid){
var jineng = Number($dataSkills[this.item().id].meta.skid);
this.subject().forceAction(jineng,this.subject()._lastTargetIndex);
}
this.updateLastTarget(target);
};
//第二个问题解决方法
BattleManager.invokeAction = function(subject, target) {
this._logWindow.push("pushBaseLine");
if (Math.random() < this._action.itemCnt(target)) {
this.invokeCounterAttack(subject, target);
this.invokeNormalAction(subject, target);
} else if (Math.random() < this._action.itemMrf(target)) {
this.invokeMagicReflection(subject, target);
} else {
this.invokeNormalAction(subject, target);
}
subject.setLastTarget(target);
this._logWindow.push("popBaseLine");
};
//使得反击可以选择不同的技能
BattleManager.invokeCounterAttack = function(subject, target) {
const action = new Game_Action(target);
action.setCounterSkill();
action.apply(subject);
this._logWindow.displayCounter(target);
this._logWindow.displayActionResults(target, subject);
};
Game_Action.prototype.setCounterSkill = function() {
if(this.subject().isActor()){
var skillarrey = this.subject().skills().filter(r => r.meta.forActor);
if(skillarrey.length > 0){
var compare = function (obj1, obj2) {
var val1 = obj1.meta.lev ? Number(obj1.meta.lev) : -1;
var val2 = obj2.meta.lev ? Number(obj2.meta.lev) : -1;
if (val1 < val2) {
return 1;
} else if (val1 > val2) {
return -1;
} else {
return 0;
}
}
skillarrey.sort(compare);
//if(this.subject().isLearnedSkill(skillarrey[0].id)){
this.setSkill(skillarrey[0].id);
//}
}else{
this.setSkill(this.subject().attackSkillId());
}
}else{
this.setSkill(this.subject().attackSkillId());
}
};
})();