Is there a way to give attacks a +Hit% bonus if attacking from the side or back? (e.g. +5% & +10 respectively)
What I did was Create 2 states, Making sure they expire after 1 turn (important)
Then in LeTBS.js
find: BattleManagerTBS.prepareDirectionalDamageBonus
Replace the function with this (The bold lines are the additions I made)
Basically what this does is adds a state to the entity making the attack (its why 1 turn is important) and takes effect before the attack. What the 1 turn does, is it applies right before the entity attacks, then after their turn, it removes them (bc the state expired)
I also added code to handle multi-attacks (phantom slash).
So if you make a move that hits from behind, then the front, it'll remove the side/back states from the entity because you don't want that bonus if you hit them from the front.
Just replace state 115 with the state you want for Back Attack, and replace 116 with the one for Side Attack and 117 with the state for front attack. If you don't want to use front attack, just put in the id for an empty state and it won't apply any effects.
BattleManagerTBS.prepareDirectionalDamageBonus = function (user, targets, item) {
var oldUserDir = user.getDir();
for (var i = 0; i < targets.length; i++) {
var entity = targets
;
if (entity === user) continue;
var dir = entity.getDir();
var effects = 0;
user.lookAt(entity.getCell());
if (user.getDir() === dir) {
//Back Attack, Add state for back attack, remove state for side/front attack:
user.battler().removeState(116);
user.battler().removeState(117);
user.battler().addState(115);
effects = Lecode.S_TBS.backDirectionalDamageEffects * 0.01;
effects += user.getDirectionalDmgBonus("back", item);
effects -= entity.getDirectionalDmgReduction("back", item);
} else if (user.getDir() === 2 && dir === 8 || user.getDir() === 8 && dir === 2 ||
user.getDir() === 4 && dir === 6 || user.getDir() === 6 && dir === 4) {
//frontAttack, remove state for back and side attack:
user.battler().removeState(115);
user.battler().removeState(116);
user.battler().addState(117);
effects = Lecode.S_TBS.frontDirectionalDamageEffects * 0.01;
effects += user.getDirectionalDmgBonus("front", item);
effects -= entity.getDirectionalDmgReduction("front", item);
} else {
//Side Attack, Add state for side attack, remove state for back/front attack:
user.battler().removeState(115);
user.battler().removeState(117);
user.battler().addState(116);
effects = Lecode.S_TBS.sideDirectionalDamageEffects * 0.01;
effects += user.getDirectionalDmgBonus("side", item);
effects -= entity.getDirectionalDmgReduction("side", item);
}
entity.battler().leTBS_setDirectionalDmgEffects(effects);
}
user.setDir(oldUserDir);
};
As an example:
Back attack without state
With the state:
(used 1000% attack bonus for dramatic effect)