Code:
//==============================
// * Check Chain Action
//==============================
BattleManager.checkChainAction = function() {
var item = this._subject.currentAction().item();
var item_notes = item.note.split(/[\r\n]+/);
item_notes.forEach(function(note) {
var note_data = note.split(': ')
if (note_data[0].toLowerCase() == "chain action"){
var par = note_data[1].split(':');
var action = $dataSkills[Number(par[0])];
var times = Math.min(Math.max(Number(par[1]),1),999);
var duration = Math.min(Math.max(Number(par[2]),10),999);
if (action) {
$gameTemp._bchainData[1] = action;
$gameTemp._bchainData[6] = times;
$gameTemp._bchainData[7] = duration;
};
};
},this);
};
//==============================
// * Invoke Action
//==============================
var _mog_bchain_bmngr_invokeAction = BattleManager.invokeAction;
BattleManager.invokeAction = function(subject, target) {
if ($gameTemp._bchainData[1]) {BattleManager.setBchainPosition(subject, target)};
_mog_bchain_bmngr_invokeAction.call(this,subject, target);
if (!target.result.i**** () && !target.isDead ()) {
this._subject.forceAction ($dataSkills[x].id, -2);
$gameTemp.clearBchain();
BattleManager.processTurn();
}else if (target.isDead ()) {
this._subject.forceAction ($dataSkills[x].id, -1);
$gameTemp.clearBchain();
BattleManager.processTurn();
}
};
//==============================
// * can Use Chain Action
//==============================
BattleManager.canUseChainAction = function() {
if (!$gameTemp._bchainData[1]) {return false};
if (!$gameTemp._bchainData[11]) {return false};
if (!this._subject) {return false};
if (!this._subject.canInput()) {return false};
if (this._subject.isDead()) {return false};
if ($gameParty.isAllDead()) {return false};
if ($gameTroop.isAllDead()) {return false};
if (!this._subject.canUse($gameTemp._bchainData[1])) {return false};
if ($gameTemp._bchainData[1].scope === 1 ||
$gameTemp._bchainData[1].scope === 7 ||
$gameTemp._bchainData[1].scope === 9) {
if (!$gameTemp._bchainData[8]) {return false};
}
return true;
};
From the last function I deleted the condition that when the target is dead, it returns false. With that I also had to fix one of the functions, because it would be completely pointless to attack dead enemies, so I set the target to -1 if target is dead, which is a random target.
Can i ask where did you find those statement like !target.result.i**** () or $dataSkills[x]
Simply put, it's knowledge, reading and understanding of the code. If we take a look at the executeChainAction function, we can see that the important line, this._subject.forceAction () takes two parameters, one of them is skill, the second one is target. However, Moghunter inputs $gameTemp._bchainData[1] as his parameter. So if you track $gameTemp._bchainData[1] in the script using Search, you'll see it defined in this function.
Code:
//==============================
// * Check Chain Action
//==============================
BattleManager.checkChainAction = function() {
var item = this._subject.currentAction().item();
var item_notes = item.note.split(/[\r\n]+/);
item_notes.forEach(function(note) {
var note_data = note.split(': ')
if (note_data[0].toLowerCase() == "chain action"){
var par = note_data[1].split(':');
var action = $dataSkills[Number(par[0])];
var times = Math.min(Math.max(Number(par[1]),1),999);
var duration = Math.min(Math.max(Number(par[2]),10),999);
if (action) {
$gameTemp._bchainData[1] = action;
$gameTemp._bchainData[6] = times;
$gameTemp._bchainData[7] = duration;
};
};
},this);
};
The important line is
Code:
$gameTemp._bchainData[1] = action;
. So when we take a look at what action is (it's defined in the same function), it's
Code:
var action = $dataSkills[Number(par[0])]
. In other words $dataSkills [parameter from the notetag].
That was when I knew how to define the case when you mess up.
When I was searching for the miss, it was a bit harder. Because I had to take a look at a different function. Browsing through the code I found out that the important one was InvokeAction function, because it is responsible for invoking the action (surprisingly). So I went to rpg_managers and searched for BattleManager.invokeAction
Code:
BattleManager.invokeAction = function(subject, target) {
this._logWindow.push('pushBaseLine');
if (Math.random() < this._action.itemCnt(target)) {
this.invokeCounterAttack(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');
this.refreshStatus();
};
And saw that there is one if which invokes counterattack, reflection or normal action. Since I wanted to know normal action, I tracked that one.
Code:
BattleManager.invokeNormalAction = function(subject, target) {
var realTarget = this.applySubstitute(target);
this._action.apply(realTarget);
this._logWindow.displayActionResults(subject, realTarget);
};
And of course there is one important line: this._action.apply, which applies the action and leads to the result.
Because this._action suggests the final result is not hidden in rpg_managers (which a search of apply only confirms), but somewhere else. In particular in rpg_objects, because that's where Game_Action.prototype is defined. So let's search for something that might look like what we're searching there.
Code:
Game_Action.prototype.apply = function(target) {
var 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();
if (result.i****()) {
if (this.item().damage.type > 0) {
result.critical = (Math.random() < this.itemCri(target));
var value = this.makeDamageValue(target, result.critical);
this.executeDamage(target, value);
}
this.item().effects.forEach(function(effect) {
this.applyItemEffect(target, effect);
}, this);
this.applyItemUserEffect(target);
}
};
And there is this one if case:
if (result.i**** ()).
Of course result, as we can see at the beginning of the function, means target.result (). So after confirming that it is what I want -
Code:
Game_ActionResult.prototype.i**** = function() {
return this.used && !this.missed && !this.evaded;
};
I know that if I negate target.result().i**** (the exclam mark in front of that), I achieve that both the cases of miss and evade are covered.
So as you can see it's partially knowledge that lets me know which file do I search for core scripts (although there are 6 files, so it's not like it would take a lot of time), partially understanding of the code (because I need to figure out what each function does and I only do that by backtracking the functions) and huge deal of backtracking and searching. I see one function calls other functions, so I track these called functions and see what's going on. No magic in that.