Run common event on level-up?

Hello everyone!

I was wondering if anyone would have a suggestion on how to go about having the game run a common event every time the player levels up? I'd like to have messages (kind of like Morrowind) when the player levels up detailing how the player has grown. I've manually adjusted every level up to reflect specific growth for the main character, and want the player to understand why growth is so uneven. So, I'd need to be able to call up a common event and then have specific messages based on the level gained. I'm pretty sure I can already set up conditional branches based on main character level, so that part should be easy.

Thanks for any suggestions people have! This community is awesome!

YT
Use one variable per actor to store old level


make a common event checking current level of each actor against the variable, displaying message and updating whenever the current level is higher.


call that common event after each event that rewards XP, and once after each battle
Hi.

Try this: (Not working in battle however :x )

Code:
module CommonEvent_OnLevelUp  ID = 1endclass Game_Interpreter    def launch_common_event(ce_id)    common_event = $data_common_events[ce_id]    if common_event      child = Game_Interpreter.new(@depth + 1)      child.setup(common_event.list, same_map? ? @event_id : 0)      child.run    end  end  endclass Game_Actor    alias lecode_lceolu_level_up level_up  def level_up    lecode_lceolu_level_up    $game_map.interpreter.launch_common_event(CommonEvent_OnLevelUp::ID)  end  end
I did something a little different, so you can call a different event for each party member:

 

module On_Level_Up # define the common event id for each party member # eq. when the first party member (index 0) level up, run the common event that has this ID and so on # you can add more if you have more party members EVENTS = {'0'=>1, '1'=>2, '2'=>3, '3'=>4 }endclass Game_Actor alias :very_old_level_up :level_up def level_up very_old_level_up member = nil for i in 0..(On_Level_Up::EVENTS.length - 1) member = i if $game_party.members && $game_party.members.id == @actor_id end $game_temp.reserve_common_event(On_Level_Up::EVENTS[member.to_s]) endendEdit: so you can use as many party members you want
Thank you both so much! I really, really appreciate it.

@Magno: I was just happy someone put something together and was trying Lecode's script when I realized the issue with more than one party member 🙂. I was actually redesigning things to make that work, but you fixed that problem. All I can say is awesome. I've tested it and it works as intended.

YT
Thank you both so much! I really, really appreciate it.

@Magno: I was just happy someone put something together and was trying Lecode's script when I realized the issue with more than one party member 🙂. I was actually redesigning things to make that work, but you fixed that problem. All I can say is awesome. I've tested it and it works as intended.

YT
Awesome! Glad to help.
module On_Level_Up # define the common event id for each party member # eq. when the first party member (index 0) level up, run the common event that has this ID and so on # you can add more if you have more party members EVENTS = {'0'=>1, '1'=>2, '2'=>3, '3'=>4 }endclass Game_Actor alias :very_old_level_up :level_up def level_up very_old_level_up member = nil for i in 0..(On_Level_Up::EVENTS.length - 1) member = i if $game_party.members && $game_party.members.id == @actor_id end $game_temp.reserve_common_event(On_Level_Up::EVENTS[member.to_s]) endendEdit: so you can use as many party members you want

Could someone format this? This gives me an error:


Ruby:
module On_Level_Up
 
  # define the common event id for each party member
  # eq. when the first party member (index 0) level up, run the common event
  # that has this ID and so on
  # you can add more if you have more party members
 
  EVENTS = {'0'=>1 }
 
end

class Game_Actor
 
  alias :very_old_level_up :level_up
  def level_up
    very_old_level_up
    member = nil
    for i in 0..(On_Level_Up::EVENTS.length - 1)
      member = i
      if
      $game_party.members && $game_party.members.id == @actor_id
      end
      $game_temp.reserve_common_event(On_Level_Up::EVENTS[member.to_s])
    end
  end
end
Could someone format this? This gives me an error:


Ruby:
module On_Level_Up
 
  # define the common event id for each party member
  # eq. when the first party member (index 0) level up, run the common event
  # that has this ID and so on
  # you can add more if you have more party members
 
  EVENTS = {'0'=>1 }
 
end

class Game_Actor
 
  alias :very_old_level_up :level_up
  def level_up
    very_old_level_up
    member = nil
    for i in 0..(On_Level_Up::EVENTS.length - 1)
      member = i
      if
      $game_party.members && $game_party.members.id == @actor_id
      end
      $game_temp.reserve_common_event(On_Level_Up::EVENTS[member.to_s])
    end
  end
end
You added an end and made the if on a line by itself when it was supposed to be the condition for member =
Ruby:
module On_Level_Up
# define the common event id for each party member
# eq. when the first party member (index 0) level up,
# run the common event that has this ID and so on
# you can add more if you have more party members
  EVENTS = {'0'=>1, '1'=>2, '2'=>3, '3'=>4 }
end
class Game_Actor
  alias :very_old_level_up :level_up
  def level_up
    very_old_level_up 
    member = nil
    for i in 0..(On_Level_Up::EVENTS.length - 1)
      member = i if $game_party.members && $game_party.members.id == @actor_id
    end
    $game_temp.reserve_common_event(On_Level_Up::EVENTS[member.to_s])
  end
end
Got it! Thank you.

Edit: Ruby too powerful to me. Error takes me to line 11. Is this a conflicting script?

Captura de pantalla (749).png
I didn't read Roninator's post before I crafted this scriptlet of mine...
So now you could use note tags instead.

Ruby:
# * Level Up Common ACE * # 
#   Scripter : Kyonides Arkanthes
#   2024-03-18

# Leave a tag in a given Actor's notebox.
# Example: <level up ce 100>
# And it will call that common event after the actor finishes leveling up.

module LvUpCm
  COMMON_EVENT = /<level up ce (\d+)>/i
end

class RPG::Actor
  def level_up_common_event
    @note[LvUpCm::COMMON_EVENT]
    $1.to_i
  end
end

class Game_Actor
  alias :kyon_lvl_up_cmmn_gm_act_lvl_up :level_up
  def level_up
    kyon_lvl_up_cmmn_gm_act_lvl_up
    call_level_up_common_event
  end

  def call_level_up_common_event
    event_id = actor.level_up_common_event
    $game_temp.reserve_common_event(event_id) if event_id > 0
  end
end
Got it! Thank you.

Edit: Ruby too powerful to me. Error takes me to line 11. Is this a conflicting script?

View attachment 298922
I'm a dummy, I missed a line. Should work now or use Kyonides script

Original thread: https://forums.rpgmakerweb.com/threads/run-common-event-on-level-up.43404/