Advantageous Battle

With random encounters I noticed that some battles can be advantageous or disadvantageous to the party. Looking through the event commands list, I couldn't find anything to manually set this up for a battle. Hopefully I'm not missing it somewhere. If it indeed does not exist, does anyone know what script call command I could put in to make a specific battle advantageous or disadvantageous?

I am not good at all with Javascript, so I am not sure how relevant this would be, but I did find this in the js files:
Code:
member.onBattleStart(advantageous);

I'm not sure if I'm looking in the right direction and if I am I don't know how to transfer that into a line of executable script. Thank you in advance to anyone who offers help. :hswt:
There isn't an "easy" standard way yet that I can find...
Created a new plugin to help with this now 😉

Basically an alias to the "start" function of the "Scene_Battle" object should do the trick.
Then in the aliased function before the "normal stuff"... set BattleManager._preemptive & BattleManager._surprise to how ever you'd like.

This yields results (setup via plugin manager parameters)
Spoiler
Code:
//=============================================================================
// RPG Maker MZ - CT_Bolt's Preemptive Plugin
//=============================================================================

/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Preemptive Plugin
* @author CT_Bolt
*
* @param Preemptive Code
* @parent ---Overlay Settings---
* @desc Preemptive Code (leave blank to not use)
* @default
*
* @param Surprise Code
* @parent ---Overlay Settings---
* @desc Surprise Code (leave blank to not use)
* @default
*
* @help
* Version: 1.00
*
*/

var CTB = CTB || {}; CTB['Preemptive']  = CTB['Preemptive'] || {};
var Imported = Imported || {}; Imported["CTB_EnemyDisplay"] = 1.00;

(($_$) => {
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.par = getPluginParameters();   
    $_$['Scene_Battle.prototype.start'] = Scene_Battle.prototype.start;
    Scene_Battle.prototype.start = function() {
        BattleManager._preemptive = $_$.par['Preemptive Code'] !== "" ? eval($_$.par['Preemptive Code']) : BattleManager._preemptive;
        BattleManager._surprise   = $_$.par['Surprise Code']   !== "" ? eval($_$.par['Surprise Code'])   : BattleManager._surprise;
        $_$['Scene_Battle.prototype.start'].apply(this, arguments);
    };
})(CTB['Preemptive']);

Edit:
Updated to v1.00 now has customization via plugin manager parameters.
With random encounters I noticed that some battles can be advantageous or disadvantageous to the party. Looking through the event commands list, I couldn't find anything to manually set this up for a battle. Hopefully I'm not missing it somewhere. If it indeed does not exist, does anyone know what script call command I could put in to make a specific battle advantageous or disadvantageous?

I am not good at all with Javascript, so I am not sure how relevant this would be, but I did find this in the js files:
Code:
member.onBattleStart(advantageous);

I'm not sure if I'm looking in the right direction and if I am I don't know how to transfer that into a line of executable script. Thank you in advance to anyone who offers help. :hswt:
Updated to make it add some customization 😉

Updated to v1.00 now has customization via plugin manager parameters.
For example you could just do like
1598489221991.png


Basically an alias to the "start" function of the "Scene_Battle" object should do the trick.
Then in the aliased function before the "normal stuff"... set BattleManager._preemptive & BattleManager._surprise to how ever you'd like.

This yields results (setup via plugin manager parameters)
Spoiler
Code:
//=============================================================================
// RPG Maker MZ - CT_Bolt's Preemptive Plugin
//=============================================================================

/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Preemptive Plugin
* @author CT_Bolt
*
* @param Preemptive Code
* @parent ---Overlay Settings---
* @desc Preemptive Code (leave blank to not use)
* @default
*
* @param Surprise Code
* @parent ---Overlay Settings---
* @desc Surprise Code (leave blank to not use)
* @default
*
* @help
* Version: 1.00
*
*/

var CTB = CTB || {}; CTB['Preemptive']  = CTB['Preemptive'] || {};
var Imported = Imported || {}; Imported["CTB_EnemyDisplay"] = 1.00;

(($_$) => {
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.par = getPluginParameters();  
    $_$['Scene_Battle.prototype.start'] = Scene_Battle.prototype.start;
    Scene_Battle.prototype.start = function() {
        BattleManager._preemptive = $_$.par['Preemptive Code'] !== "" ? eval($_$.par['Preemptive Code']) : BattleManager._preemptive;
        BattleManager._surprise   = $_$.par['Surprise Code']   !== "" ? eval($_$.par['Surprise Code'])   : BattleManager._surprise;
        $_$['Scene_Battle.prototype.start'].apply(this, arguments);
    };
})(CTB['Preemptive']);
Wow, thank you so so much. I'm flattered that you'd ask me for input like this! Sadly, this is the first time I've ever used the battling system and so I have no idea where to start with suggestions. But I hope others might see this and message you some ideas. ♥

I was hoping there was a simple way because me and my friend are doing a little challenge where we are only allowed to use the base game and no plugins to create our short game.

Still, if that changes we'll be 100% using your plugin. I'm always so impressed with people who can do things like this and share it so freely with the community!
I was hoping there was a simple way because me and my friend are doing a little challenge where we are only allowed to use the base game and no plugins to create our short game.
Hmm... plugin free ay?
Ok here ya go but does require one "setup" event to run preferably at game start.
So it's like this:

1. Run a setup event on the starting map.
Spoiler
Setup event:
1598490444123.png
Spoiler: Highlighted Script
Code:
const preemptiveVar = 1, surpriseVar = 2;
$gameVariables.setValue(preemptiveVar, ""); $gameVariables.setValue(surpriseVar, "");
BattleManager['Scene_Battle.prototype.start'] = Scene_Battle.prototype.start;
Scene_Battle.prototype.start = function() {
  if ($gameVariables.value(preemptiveVar) !== "") BattleManager._preemptive = eval($gameVariables.value(preemptiveVar));
  if ($gameVariables.value(surpriseVar) !== "") BattleManager._surprise   = eval($gameVariables.value(surpriseVar));
  BattleManager['Scene_Battle.prototype.start'].apply(this, arguments);
};
2. Then at any point you can change the variables to adjust as needed to determine and change as needed.
Spoiler
1598490655528.png
3. To disable them just set the variables to blank script
Spoiler
1598491118130.png
Make sense?
Oh my gosh!!! ct_bolt, you made my day thank you. I can't believe you took the time to do this. <3 Everyone here is so giving and kind. I'm speechless. Lots of virtual hugs to you. Sorry for late reply, I was making dinner and didn't get back until now.
Oh my gosh!!! ct_bolt, you made my day thank you. I can't believe you took the time to do this. <3 Everyone here is so giving and kind. I'm speechless. Lots of virtual hugs to you. Sorry for late reply, I was making dinner and didn't get back until now.
Oh goodness *blush* *blush*
No problem at all. Glad to help out.

Happy Game Making! ☺️

PS. Hope dinner is/was yummy! :popcorn:
Updated to make it add some customization 😉

Updated to v1.00 now has customization via plugin manager parameters.
For example you could just do like View attachment 157697

Basically an alias to the "start" function of the "Scene_Battle" object should do the trick.
Then in the aliased function before the "normal stuff"... set BattleManager._preemptive & BattleManager._surprise to how ever you'd like.

This yields results (setup via plugin manager parameters)
Spoiler
Code:
//=============================================================================
// RPG Maker MZ - CT_Bolt's Preemptive Plugin
//=============================================================================

/*:
* @target MZ
* @plugindesc v1.00 CT_Bolt's Preemptive Plugin
* @author CT_Bolt
*
* @param Preemptive Code
* @parent ---Overlay Settings---
* @desc Preemptive Code (leave blank to not use)
* @default
*
* @param Surprise Code
* @parent ---Overlay Settings---
* @desc Surprise Code (leave blank to not use)
* @default
*
* @help
* Version: 1.00
*
*/

var CTB = CTB || {}; CTB['Preemptive']  = CTB['Preemptive'] || {};
var Imported = Imported || {}; Imported["CTB_EnemyDisplay"] = 1.00;

(($_$) => {
    function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.par = getPluginParameters(); 
    $_$['Scene_Battle.prototype.start'] = Scene_Battle.prototype.start;
    Scene_Battle.prototype.start = function() {
        BattleManager._preemptive = $_$.par['Preemptive Code'] !== "" ? eval($_$.par['Preemptive Code']) : BattleManager._preemptive;
        BattleManager._surprise   = $_$.par['Surprise Code']   !== "" ? eval($_$.par['Surprise Code'])   : BattleManager._surprise;
        $_$['Scene_Battle.prototype.start'].apply(this, arguments);
    };
})(CTB['Preemptive']);

excuse my noobness , but I added the plugin . is there a way i can in the battle test be able to invoke this plugin to see the diffrent results?

Original thread: https://forums.rpgmakerweb.com/threads/advantageous-battle.126188/