本帖最后由 rfvtgbzxc 于 2023-5-29 12:40 编辑
actor是泛指类型为Game_Actor的对象,需要根据语境去找。实际上如果希望这个特性更通用,不限敌我,应该是泛指Game_Battler,同时包括了Game_Actor和Game_Enemy。
基于这个前提的代码:(想了下还是不改基类吧,两种都在Game_Action里改):
(攻击概率部分有更新,现在加到了攻击附带状态的概率上)
Game_Action.prototype.itemEffectAddAttackState = function(target, effect) { for (const stateId of this.subject().attackStates()) { let chance = effect.value1; chance *= target.stateRate(stateId); // 新修改的行 chance *= this.subject().attackStatesRate(stateId) + this.subject().states().reduce((current, state)=>current + Number(state.meta["状态额外成功率"]?.match(/(.\d+)%/)[1] ?? 0), 0) / 100; chance *= this.lukEffectRate(target); if (Math.random() < chance) { target.addState(stateId); this.makeSuccess(target); } } }; Game_Action.prototype.itemEffectAddNormalState = function (target, effect) { let chance = effect.value1; // 新加入的行 chance += this.subject().states().reduce((current, state)=>current + Number(state.meta["状态额外成功率"]?.match(/(.\d+)%/)[1] ?? 0), 0) / 100; if (!this.isCertainHit()) { chance *= target.stateRate(effect.dataId); chance *= this.lukEffectRate(target); } if (Math.random() < chance) { target.addState(effect.dataId); this.makeSuccess(target); } };
Game_Action.prototype.itemEffectAddAttackState = function(target, effect) {
for (const stateId of this.subject().attackStates()) {
let chance = effect.value1;
chance *= target.stateRate(stateId);
// 新修改的行
chance *= this.subject().attackStatesRate(stateId) + this.subject().states().reduce((current, state)=>current + Number(state.meta["状态额外成功率"]?.match(/(.\d+)%/)[1] ?? 0), 0) / 100;
chance *= this.lukEffectRate(target);
if (Math.random() < chance) {
target.addState(stateId);
this.makeSuccess(target);
}
}
};
Game_Action.prototype.itemEffectAddNormalState = function (target, effect) {
let chance = effect.value1;
// 新加入的行
chance += this.subject().states().reduce((current, state)=>current + Number(state.meta["状态额外成功率"]?.match(/(.\d+)%/)[1] ?? 0), 0) / 100;
if (!this.isCertainHit()) {
chance *= target.stateRate(effect.dataId);
chance *= this.lukEffectRate(target);
}
if (Math.random() < chance) {
target.addState(effect.dataId);
this.makeSuccess(target);
}
};
subject()是Game_Action实例特有的函数,很有用,可以使用它获取到本次行动的发起者。
这种不依靠插件,为开发者提供切入点思路的帖子平时看见得比较少,所以回复得详细一些,希望能有帮助。
|