Returning Stolen Money

In my game, one ability that certain enemies have is the chance to steal 1/2 the player's gold.
I got that setup just fine, but I'm having trouble setting up a way to return it. I've tried doing an event page in the troops were such enemies are present, but it doesn't work when that enemy is either the only one or killed last.
Bascially, is there a better way to do this?
Oh. That's more complex.
You need a Common Event that will be called.
The common event will get the Current Gold BEFORE subtracting the cash and set it in VarA.
Then you subtract the cash using the formula.
Finally you get the remaining gold into another variable VarB.

VarA subtract VarB. TADAAAAA
I would do it without saving the amount of money in a variable but rather increasing a variable each time you successfully steal money.
Take a look at the following pseudocode
Code:
If (money is stolen)
 > VarA += amount stolen
endIf
This way if you want to give it back you simply add the value stored in VarA to party gold. The good point about this method is that it keeps track of the total amount of gold stolen. Of course the fact that you should use a skill that calls a common event, as @Dreadshadow mentioned, remains unchanged. That is the correct way to go.

Spoiler: What you should put in your common event
Use a script call and copy/paste this:
Code:
var_id = pick_a_variable_id # Change this
stolen_gold = $game_party.gold / 2
$game_party.gain_gold(-stolen_gold)
$game_variables[var_id] += stolen_gold

Just put your variable ID instead of "pick_a_variable_id" and the trick is done.

You could use the stored amount of gold stolen so that the player can find the missing gold somewhere in the game or you could just reset it and use that variable again. How you use it is up to you.

Pick either solution since the one mentioned above mine is also a very good solution. The choice is yours.
hes-right-you-know-32644779.png

I just wrote the first thing that came up to my mind.
This approach is quite better!
hes-right-you-know-32644779.png

I just wrote the first thing that came up to my mind.
This approach is quite better!

OK, I'm trying out your guys ideas.
One problem: You guys forgot to mention when I should trigger the Common Event, which is the other problem I had.
It can be called by the skill that uses steal.

Original thread: https://forums.rpgmakerweb.com/threads/returning-stolen-money.107640/