MZ Display/Show final chance to hit/hit rate after evasion and skill success chance

I've been skimming the threads from various topics and couldn't find a plugin for RPGMaker MZ that displays hit chance when hovering over an enemy battler.

Description:
When a battle is happening, I would like the player to be able to see their hit chance (as a percentage) after a skill is selected and they're hovering over an enemy battler. This would (ideally) be functional for both SV and regular battle views.
For single target skills, this would display the hit chance next to the targeted enemy battler, ideally to the side of the battler rather than above or below.
For AoE skills, this would display the hit chance next to every targeted battler, using the same placement as described above.
For AoE skills that hit everyone (including allies), the hit chance would only be displayed on enemies and not allies.
If targeting an ally, there would be no hit chance displayed (for things like buffs and such, as I don't intend to have any attack be targeted against allies).
For all of the above, if a skill is a "Certain Hit" it would state "Guaranteed Hit" next to the enemy instead of any numerical value.
For all of the above, it would only display this hit chance after a skill has been chosen but before the skill is finalized on a given target.

Ideally the formula would be customizable, giving a setting where a javascript line could be written for the formula. However, the default formula would be something like this:
[(User Hit Rate - Target Evasion Rate) * User Skill Chance] = display as percentage (e.g: 75%)
If (User Skill = Certain Hit) = display as "Guaranteed Hit"

Extra:
A minor question as well, how do the more experienced javascript users find script references? I know there's the links to the google sheets that have lists of different script references and such, however sometimes I'll see people use things that aren't listed in those documents and I wonder where they figure this stuff out.
An example, someone in another thread was giving suggestions on how I could make a script for this request here, and the script he wrote used something called "Window_BattleEnemy.prototype.select" which I couldn't find any info on what it is and where I can find the use case for. I'm obviously a novice to scripting and coding, so I'm a little lost on where this stuff can be found.

Thanks in advance.
Unfortunately that would require a plugin to rewrite the entire skill process, because by default evasion works independently of hit chance.

you can check the default process here:
Unfortunately that would require a plugin to rewrite the entire skill process, because by default evasion works independently of hit chance.

you can check the default process here:
The VisuStella Core Engine plugin already does that actually, making physical attacks calculated as (Hit Rate - Eva). The plugin I'm requesting is to display the hit chance on its own with an option to set your own formula for the calculation (so it can be used alongside other plugins that may change how hit rate is calculated). I just requested the default to be (Hit Rate - Eva) since that's what I'm using with the Core Engine plugin.
I extended a bit the code I wrote in the VS notetag thread. Now it has checks for magical and certain hit. I don't think you need to check "vs all" attacks, because that doesn't even go to selection screen, right? I also made it create just one sprite which it shows and hides and moves. But yeah, I'm not sure if you need to destroy the sprite at battle end or if it does it automatically and if it'd be better to use the addchild to some other place. Maybe someone else can answer those. You need to add this stuff as a plugin file. You can change the position by adding/subtracting where it sets the sprite x and y positions. For your other question, you can check the code in the rpg maker js files.

Window_BattleEnemy.prototype.initialize = function(rect) {
this._enemies = [];
Window_Selectable.prototype.initialize.call(this, rect);
this.refresh();
const bitmap = new Bitmap(200, 100);
bitmap.fontSize = 24;
this._hitPercentSprite = new Sprite();
this._hitPercentSprite.bitmap = bitmap;
SceneManager._scene.addChild(this._hitPercentSprite);
this._hitPercentSprite.hide();
this.hide();
};


Window_BattleEnemy.prototype.show = function() {
this.refresh();
this.forceSelect(0);
$gameTemp.clearTouchState();
Window_Selectable.prototype.show.call(this);
if (this._hitPercentSprite && this.enemy()) {
this._hitPercentSprite.x = this.enemy().screenX();
this._hitPercentSprite.y = this.enemy().screenY()-50;
this._hitPercentSprite.show();
}
};


Window_BattleEnemy.prototype.hide = function() {
Window_Selectable.prototype.hide.call(this);
$gameTroop.select(null);
if (this._hitPercentSprite) {
this._hitPercentSprite.hide();
}
};


Window_BattleEnemy.prototype.select = function(index) {
this._index = index;
this.refreshCursor();
this.callUpdateHelp();
if (this._hitPercentSprite && BattleManager._currentActor && BattleManager.inputtingAction() && BattleManager.inputtingAction().item() && this.enemy() && !BattleManager.inputtingAction().isItem()) {
this._hitPercentSprite.bitmap.clear();
const currentAction = BattleManager.inputtingAction();
const currentActionItem = currentAction.item();
const currentActorHit = BattleManager._currentActor.hit;
const enemyEva = this.enemy().eva;
const enemyMev = this.enemy().mev;
const successRate = currentActionItem.successRate / 100;
const enemyX = this.enemy().screenX();
const enemyY = this.enemy().screenY()-50;
let hitRate = "";
if (currentAction.isCertainHit()) {
hitRate = "Guaranteed hit";
} else if (currentAction.isMagical()) {
hitRate = (Math.round((successRate*(currentActorHit - enemyMev)*100))).toString() + "%";
} else {
hitRate = (Math.round((successRate*(currentActorHit - enemyEva)*100))).toString() + "%";
}
this._hitPercentSprite.bitmap.drawText(hitRate, 0, 0, 200, 100, "left");
this._hitPercentSprite.x = this.enemy().screenX();
this._hitPercentSprite.y = this.enemy().screenY()-50;
}
};
I extended a bit the code I wrote in the VS notetag thread. Now it has checks for magical and certain hit. I don't think you need to check "vs all" attacks, because that doesn't even go to selection screen, right? I also made it create just one sprite which it shows and hides and moves. But yeah, I'm not sure if you need to destroy the sprite at battle end or if it does it automatically and if it'd be better to use the addchild to some other place. Maybe someone else can answer those. You need to add this stuff as a plugin file. You can change the position by adding/subtracting where it sets the sprite x and y positions. For your other question, you can check the code in the rpg maker js files.

Window_BattleEnemy.prototype.initialize = function(rect) {
this._enemies = [];
Window_Selectable.prototype.initialize.call(this, rect);
this.refresh();
const bitmap = new Bitmap(200, 100);
bitmap.fontSize = 24;
this._hitPercentSprite = new Sprite();
this._hitPercentSprite.bitmap = bitmap;
SceneManager._scene.addChild(this._hitPercentSprite);
this._hitPercentSprite.hide();
this.hide();
};


Window_BattleEnemy.prototype.show = function() {
this.refresh();
this.forceSelect(0);
$gameTemp.clearTouchState();
Window_Selectable.prototype.show.call(this);
if (this._hitPercentSprite && this.enemy()) {
this._hitPercentSprite.x = this.enemy().screenX();
this._hitPercentSprite.y = this.enemy().screenY()-50;
this._hitPercentSprite.show();
}
};


Window_BattleEnemy.prototype.hide = function() {
Window_Selectable.prototype.hide.call(this);
$gameTroop.select(null);
if (this._hitPercentSprite) {
this._hitPercentSprite.hide();
}
};


Window_BattleEnemy.prototype.select = function(index) {
this._index = index;
this.refreshCursor();
this.callUpdateHelp();
if (this._hitPercentSprite && BattleManager._currentActor && BattleManager.inputtingAction() && BattleManager.inputtingAction().item() && this.enemy() && !BattleManager.inputtingAction().isItem()) {
this._hitPercentSprite.bitmap.clear();
const currentAction = BattleManager.inputtingAction();
const currentActionItem = currentAction.item();
const currentActorHit = BattleManager._currentActor.hit;
const enemyEva = this.enemy().eva;
const enemyMev = this.enemy().mev;
const successRate = currentActionItem.successRate / 100;
const enemyX = this.enemy().screenX();
const enemyY = this.enemy().screenY()-50;
let hitRate = "";
if (currentAction.isCertainHit()) {
hitRate = "Guaranteed hit";
} else if (currentAction.isMagical()) {
hitRate = (Math.round((successRate*(currentActorHit - enemyMev)*100))).toString() + "%";
} else {
hitRate = (Math.round((successRate*(currentActorHit - enemyEva)*100))).toString() + "%";
}
this._hitPercentSprite.bitmap.drawText(hitRate, 0, 0, 200, 100, "left");
this._hitPercentSprite.x = this.enemy().screenX();
this._hitPercentSprite.y = this.enemy().screenY()-50;
}
};
Sorry for late reply, was busy yesterday.
Thanks for doing all of this, I'll test it out later and see if it works as intended.

On the other question, you just look at the js files? How do you know what to look for in them when thinking up something for a plugin?
Ok cool.
The files are somewhat divided by content. For windows look for the window file. The functions etc names tell what they're doing. Like if you want something to happen when you select (in this case meaning put the cursor on the item) you can add to that method (like I said in the other thread, it'd be better to alias stuff). Use the prototype property on the functions to add stuff so it's inherited when you create an instance with "new", like when it creates the windows in battle scene.
Ok cool.
The files are somewhat divided by content. For windows look for the window file. The functions etc names tell what they're doing. Like if you want something to happen when you select (in this case meaning put the cursor on the item) you can add to that method (like I said in the other thread, it'd be better to alias stuff). Use the prototype property on the functions to add stuff so it's inherited when you create an instance with "new", like when it creates the windows in battle scene.
Aight, thanks. I'll spend some time reading through the js files when I get some free time to start learning more about how things work, maybe even try to make my own plugins.

Uhhhh just a small side question: the plugin you wrote works exactly as I want, however I'd like to use the system font that RPGMaker uses (since you can change that in the database to use a custom font) for the text drawn when the 'chance to hit' pops up. How would that be implemented?
My skills are really bad when it comes to stuff like fonts (among many other things). If you look at the core files, in the basic bitmap initialize it sets: this.fontFace = "sans-serif";Maybe try in what I posted above after the new bitmap stuff, like bitmap.fontFace = "rmmz-mainfont"; But there should be a lot of people here who know this stuff a lot better that I do.
My skills are really bad when it comes to stuff like fonts (among many other things). If you look at the core files, in the basic bitmap initialize it sets: this.fontFace = "sans-serif";Maybe try in what I posted above after the new bitmap stuff, like bitmap.fontFace = "rmmz-mainfont"; But there should be a lot of people here who know this stuff a lot better that I do.
Sure, I'll try looking through the files then. Thanks for all the help, you've been grand m8.

Original thread: https://forums.rpgmakerweb.com/threads/display-show-final-chance-to-hit-hit-rate-after-evasion-and-skill-success-chance.180149/