じ☆ve冰风 发表于 2026-7-25 16:51:36

Level Up Common XP

Level Up Common XP

by Kyonides​

Introduction

This simple scriptlet will let you call a given Common Event by configuring the ACTORS_EVENT in such a way that it will find the target actor's current level and call the common event if any was found.

How does it find the right common event?

Well, it is very simple to explain. The scriptlet will look for the lowest level possible.
If you set a level like 5 and your actor has just reached level 2, it will trigger the level 5's common event.
Once that actor's level goes beyond that point, it will have to search for a higher level if available.
If no other level is available, nothing will happen.
If you wanna set a specific common event for the remaining levels, 100 or your game's maximum level will suffice.

I embedded some comments in the script to help you add more actors.
Right now it will only work with
Aluxes aka Alex.

EDIT: Updated

                Ruby:       
# * Level Up Common XP * #
#   Scripter : Kyonides Arkanthes
#   2024-03-22

# This scriptlet allows you to call a common event after the actor finishes the
# leveling up process. To accomplish this task, you will have to configure
# the ACTORS_EVENT hash accordingly.
# To add an Actor you need an ActorID & 1 or more Level => CmEvID key pairs.

module LvUpCm
ACTORS_EVENT = {} # Leave it alone!
ACTORS_EVENT.default = {} # Leave it alone!
# Follow this pattern:
# ACTORS_EVENT = { 5 => 1, 10 => 2, 100 => 3, etc. }
ACTORS_EVENT = { 4 => 1, 8 => 2, 100 => 3 }
end

class Game_Actor
alias :kyon_lvl_up_cmmn_gm_act_exp_set :exp=
def exp=(new_exp)
    old_level = @level
    kyon_lvl_up_cmmn_gm_act_exp_set(new_exp)
    process_level_up_common_event(old_level)
end

def process_level_up_common_event(old_level)
    return if @level <= old_level
    event_group = LvUpCm::ACTORS_EVENT[@actor_id]
    return if event_group.empty?
    key = event_group.keys.sort.find {|n| @level <= n }
    $game_temp.common_event_id = event_group || 0
end
end


Download Demo​

Terms & Conditions

Free for use in ANY game.
Due credit is mandatory.
Mention this forums in your game credits.
That's it!



本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/level-up-common-xp.167016/
页: [1]
查看完整版本: Level Up Common XP