MZ Add a preemptive/surprise chance at event-triggered battles

I'm making an item that prevents surprise attacks and raises preemptive chance, but I plan to use event-triggered battles instead of random encounters (also the default odds are really low). So I'm trying my luck to find a plugin or directions to add a script/command that lets me start a battle with custom preemptive/surprise odds that are affected by the "cancel surprise" and "raise preemptive" traits.
I think this needs to go to "Learning Javascript" or "Plugin Requests" but in any case this might be a good starting point?

I have moved this thread from RPG Maker MZ Support to JS Plugin Requests.
You can check for the traits using Conditional Branch -> Script:
  • $gameParty.hasCancelSurprise()
  • $gameParty.hasRaisePreemptive()
Thanks a lot for the help! I got a lil system going with Cae's plugin and a random variable, setting a number from 1 to 10 to preemptive and another for surprise. Then used that script for a set of branches to account for cancel surprise and raise preemptive.
That way there's the equivalent of a 10% chance for surprise/pre-emptive battle without any traits, which change to 0% and 20% respectively if any or both traits are equipped.

Original thread: https://forums.rpgmakerweb.com/threads/add-a-preemptive-surprise-chance-at-event-triggered-battles.163427/