Force preemptive and surprise attack

Hi,

I would like to know how I can force a battle to start with preemptive attack or surprise attack.
I had to write a script for that, as the only way I found for this was to turn on a switch when I wanted the fight to be a surprise attack (similar for pre-emptive attack). The harder part is forcing it for fights you put on the map, as that never checks for surprise or preemptive, so I had to overwrite how that was done.

Let me see if I have it somewhere.

Edit: Here it is. If you have Yanfly's encounter control script, put it below that one. If you have other encounter control scripts, if might be incompatable, as I only wrote it to work with Yanflys (as it is for my project at the moment). http://pastebin.com/CDMuvkNM

You may wish to change the line that says Encounter_Max to a number besides 30, as that will make it so that after 30 fights on the same map, no more random battles occur until you leave the map (or load a save game).

Original thread: https://forums.rpgmakerweb.com/threads/force-preemptive-and-surprise-attack.39025/