MV HELP! How to edit the code for battle processing.

Hi all! What I want to do is, when X switch is ON, instead of going to a battle, have a X variable that counts how many battles the player would have run into if X switch was OFF, if X switch is OFF, run into battles normally.

EXAMPLE
Battle Processing
if X switch is on
count battle in variable
dont run into battle
else
run battle normally
end


Thanks!
run a conditional branch first:

If: Switch X = OFF
run battle
else
variable battle +=1
end

but I dont quite understand what the variable does otherwise.

you can reversed the above to ON and do the variable first, if it isn't
ON, it will run a battle, as long the top condition = true.
Thank you for your answer, I think i didnt explain what I wanted correctly.

I wanted to do the battle process ON RANDOM ENCOUNTERS. And I figured it out too.

I added the script:

if ($gameSwitches.value(x) == true) { $gameVariables.setValue(x, $gameVariables.value(x) + 1) return false; } else { return true;

On the Game_Player.prototype.executeEncounter function.
I still have no clue what it is what it does 😛

as the setValue and value are both the same?
I'm glad you figure it out though, so good luck on your project 🙂

also curious how that works out on the encounter when I got the chance
to playtest it 🙂
@Magusalfador makes the code as a plugin. That way, you know which part of the code you have edited.
as the setValue and value are both the same?
setValue sets the value - says "make this variable equal to this."

value returns the value - tells you "this variable is equal to this"

so $gameVariables.setValue(x, $gameVariables.value(x) + 1) is simply adding 1 to the variable with id "x".

Original thread: https://forums.rpgmakerweb.com/threads/help-how-to-edit-the-code-for-battle-processing.144562/