Is there a way to make beating Random Encounters trigger an event?

My EXP system has been replaced with a variable based one in game. As such... I need events to activate upon an enemy's defeat to add proper EXP.
Is there a way to make it so that beating a random encounter causes a common event to activate, while running away does not?
Not without a plugin, unless you ditch "random" encounters and add an event that simulates them.
beating a random encounter causes a common event to activate
Try this script. put below materials in your script list.
Ruby:
module R2_CECV
  CE = 1 #  change the number to the common event you wish to use
end
module BattleManager
  class << self
    alias r2_encounter_victory_process  process_victory
  end
  def self.random_battle_encounter(set = false)
    @totally_random = set
  end
  def self.process_victory
    $game_temp.reserve_common_event(R2_CECV::CE) if @totally_random
    r2_encounter_victory_process
    @totally_random = false
  end
end
class Scene_Map < Scene_Base
  def update_encounter
    if $game_player.encounter
      BattleManager.random_battle_encounter(true)
      SceneManager.call(Scene_Battle)
    end
  end
end
Thanks
Try this script. put below materials in your script list.
Ruby:
module R2_CECV
  CE = 1
end
module BattleManager
  class << self
    alias r2_encounter_victory_process  process_victory
  end
  def self.random_battle_encounter(set = false)
    @totally_random = set
  end
  def self.process_victory
    $game_temp.reserve_common_event(R2_CECV::CE) if @totally_random
    r2_encounter_victory_process
    @totally_random = false
  end
end
class Scene_Map < Scene_Base
  def update_encounter
    if $game_player.encounter
      BattleManager.random_battle_encounter(true)
      SceneManager.call(Scene_Battle)
    end
  end
end
Thank you so much.
How do I use this to select which random event to activate?
select which random event to activate
You don't select random events. That's the whole purpose of random.
If you are using events on the map then it is staged.
And if that's the case, then this little script won't do what you want.
You had said a random encounter, this will let you run whatever common event you specify, to run after winning a random battle. If you only want to run the event after specific battles you need to be a LOT more descriptive on what you are doing, where it will happen, and how it is to be controlled.
Wow... that was bad wording on my part.

I was just trying to figure out how to specify the common event in question.
Make clear to the program which event I'm trying to activate.
Make clear to the program which event I'm trying to activate.
Which common event?
I updated the code above to make it more clear.
CE = 1 # change the number to the common event you wish to use
Basically... I want it so that whenever a player defeats a random encounter, Common event 5 is activated.
I want it so that whenever a player defeats a random encounter, Common event 5 is activated.
then change the 1 to a 5
Perfect

Thank you very much for your help, I appreciate it.

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-make-beating-random-encounters-trigger-an-event.133018/