[Ace] Stealing from NPCs

Hi there! This is my first post, I'm pretty sure I chose the right section, if not, I'm really sorry.

I managed to create a script which lets the main character steal gold or items from NPCs, This is the common event:

Spoiler
$game_variables[1] = rand($game_variables[12]) - $game_party.leader.agiif $game_variables[1] < 0$game_switches[9] = trueendif $game_variables[1] > $game_variables[12]/2$game_switches[10] = trueend where v[12] is "attention level", switch[9] checks if you stole something, and switch[10] checks if you got caught 
so I would only assign each NPC an "attention level" value, and then call the event, choosing what item to give if switch[9] is on, the main problem is that it looks a bit to heavy (Considering I would have to add all of this to every NPC event): 

Spoiler
vw1NvQda.jpg
I'm sure it could be simpler, but I can't figure it out  >_> . Is there a way to transform that in a simple: set v[12] and reward, call common event? (those text messages don't change from Npc to Npc) I'm grateful for any help!
First, before anyone got confused: what you have done is called eventing, not scripting, in the RM-Community - scripting is much more complex and done in the script editor.


That said, yes, all event commands can be transferred to the common event - you just need some more variables to transfer the data from the map event to the common event.


Then everything can be handled in the common event instead of the map event.


Basically, you'll need one variable to set the amount of gold stolen and one variable for the ID of an item (if it is possible to steal items, that is more complex.


The change gold command in the common event can be set to read from the variable directly, but if you want to be able to steal an item in the common event the variable needs to be checked by conditional branches to identify the item.


The only thing that would be a bit complex is to get back the setting for the self-switch - you'll have to use a regular switch for the result of the common event and then set the self-switch of the event depending on that result.

Original thread: https://forums.rpgmakerweb.com/threads/ace-stealing-from-npcs.37372/