这是升级加点脚本,非常感谢{:2_36:} #============================================================================== # 本脚本来自(不能发链接,所以我给删了,抱歉= =),使用和转载请保留此信息 #============================================================================== # 脚本使用设定: LEVEL_UP_POINT = 3 # 每升一级所增加的点数 LEVEL_UP_VARIABLE = 100 # 储存角色点数的变量编号与角色id编号的差值 # 默认情况 = 100, # 则是数据库里1号角色的加点数存于101号变量 # 3号角色的加点数存于103号变量。 # 你可以直接操作变量赠与角色可分配点数 # 每增加一次点数,各项能力值的变化:357-410行 # 使用方法介绍: # 本脚本不会取代原来的升级自动加点 也就是说,默认的升级还在,但可以用这个功能手动追加点数。 # 如果你想纯粹使用手动加点(而升级不提升能力),只要把数据库中角色升级能力, # 1-99级全部等于一个相同数值就行了。 # 呼唤加点场景的方法:$scene = Scene_Lvup.new(角色编号,返回菜单编号)。 # 默认都是0号 # 加点场景中,page up,page down换人,如果想加点完毕后返回地图, # 464行$scene = Scene_Menu.new(0)改为$scene = Scene_Map.new # 推荐脚本搭配:魔法商店脚本,两者结合,制作自由型RPG #============================================================================== # ■ Window_Command #------------------------------------------------------------------------------ # 一般的命令选择行窗口。(追加定义) #============================================================================== class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # ● 项目有效化 # index : 项目编号 #-------------------------------------------------------------------------- def able_item(index) draw_item(index, normal_color) end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ # 处理角色的类。(再定义) #============================================================================== class Game_Actor < Game_Battler def level_up @level += 1 $game_variables[self.id + LEVEL_UP_VARIABLE] += LEVEL_UP_POINT for learning in self.class.learnings learn_skill(learning.skill_id) if learning.level == @level end end end #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ # 游戏中全部窗口的超级类(追加定义) #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● 描绘 HP # actor : 角色 # x : 描画目标 X 坐标 # y : 描画目标 Y 坐标 # width : 描画目标的宽 #-------------------------------------------------------------------------- def draw_actor_hp_lvup(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x , y, 96, 32, "最大" + Vocab::hp) if $temp_hp == 0 self.contents.font.color = normal_color self.contents.draw_text(x + 120 , y, 48, 32, actor.maxhp.to_s, 2) else maxhp = actor.maxhp + $temp_hp self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 120 , y, 48, 32, maxhp.to_s ,2) self.contents.font.color = normal_color self.contents.draw_text(x + 155, y, 36, 32, "( ", 2) if $temp_hp >=0 self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 155, y, 36, 32, " +",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 155, y, 36, 32, " -",2) end self.contents.draw_text(x + 200, y, 36, 32, $temp_hp.to_s, 2) self.contents.font.color = normal_color self.contents.draw_text(x + 215, y, 36, 32, ")", 2) end end #-------------------------------------------------------------------------- # ● 描绘 MP # actor : 角色 # x : 描画目标 X 坐标 # y : 描画目标 Y 坐标 # width : 描画目标的宽 #-------------------------------------------------------------------------- def draw_actor_mp_lvup(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x , y, 96, 32, "最大" + Vocab::mp) if $temp_mp == 0 self.contents.font.color = normal_color self.contents.draw_text(x + 120 , y, 48, 32, actor.maxmp.to_s, 2) else maxmp = actor.maxmp + $temp_mp self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 120 , y, 48, 32, maxmp.to_s ,2) self.contents.font.color = normal_color self.contents.draw_text(x + 155, y, 36, 32, "( ", 2) if $temp_mp >=0 self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 155, y, 36, 32, " +",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 155, y, 36, 32, " -",2) end self.contents.draw_text(x + 200, y, 36, 32, $temp_mp.to_s, 2) self.contents.font.color = normal_color self.contents.draw_text(x + 215, y, 36, 32, ")", 2) end end #-------------------------------------------------------------------------- # ● 描绘能力值 # actor : 角色 # x : 描画目标 X 坐标 # y : 描画目标 Y 坐标 # type : 能力值种类 (0~4) #-------------------------------------------------------------------------- def draw_actor_lvup(actor, x, y, type) # 定义数字颜色 lvup = normal_color upcolor = Color.new(255, 128, 128, 255) self.contents.font.color = normal_color case type when 0 parameter_name = Vocab::atk parameter_value = actor.atk parameter_value_temp = parameter_value + $temp_atk if $temp_atk != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_atk >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_atk.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 1 parameter_name = Vocab::def parameter_value = actor.def parameter_value_temp = parameter_value + $temp_def if $temp_def != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_def >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_def.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 2 parameter_name = Vocab::agi parameter_value = actor.agi parameter_value_temp = parameter_value + $temp_agi if $temp_agi != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_agi >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_agi.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 3 parameter_name = Vocab::spi parameter_value = actor.spi parameter_value_temp = parameter_value + $temp_spi if $temp_spi != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_spi >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_spi.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 4 parameter_name = "剩余点数" parameter_value = $point if $point != 0 lvup = upcolor end end self.contents.font.size = 16 if type == 4 self.contents.font.color = system_color if type != 4 then self.contents.draw_text(x, y, 120, 32, parameter_name) else self.contents.draw_text(x, y, 120, 24, parameter_name) end self.contents.font.color = normal_color if type != 4 self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s) else self.contents.draw_text(x + 68, y, 36, 24, parameter_value.to_s) end if type != 4 self.contents.draw_text(x + 150, y, 36, 32, "→") end self.contents.font.color = lvup self.contents.draw_text(x + 180, y, 60, 32, parameter_value_temp.to_s) self.contents.font.color = normal_color end end class Window_Lvpoint < Window_Base def initialize super(0,198,128,58) refresh end def refresh self.contents.clear draw_actor_lvup(@actor, 0, 0, 4) end end #============================================================================== # ■ Window_lvup #------------------------------------------------------------------------------ # 显示升级状态窗口。 #============================================================================== class Window_Lvup < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 #-------------------------------------------------------------------------- def initialize(actor) super(0, 0, 416, 256) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear draw_actor_graphic(@actor, 30, 80) draw_actor_name(@actor, 4, 0) draw_actor_class(@actor, 96, 0) draw_actor_level(@actor, 224, 0) draw_actor_state(@actor, 96, 32) draw_actor_hp_lvup(@actor, 96, 32) draw_actor_mp_lvup(@actor, 96, 64) draw_actor_lvup(@actor, 4, 96, 0) draw_actor_lvup(@actor, 4, 128, 1) draw_actor_lvup(@actor, 4, 160, 2) draw_actor_lvup(@actor, 4, 192, 3) end end #============================================================================== # ■ Window_Help #------------------------------------------------------------------------------ # 特技及物品的说明、角色的状态显示的窗口。 #============================================================================== class Window_Lvup_Help < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 256, 544, 160) self.contents = Bitmap.new(width - 32, height - 32) @test = "" #——这个东西用来检测,节约内存专用 end #-------------------------------------------------------------------------- # ● 设置文本 #-------------------------------------------------------------------------- def lvup_text(text1, text2 = nil, text3 = nil, text4 = nil) if @test != text1 @test = text1 else return end self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(4, 0, self.width - 40, 32, text1) if text2 != nil self.contents.draw_text(4 , 32, self.width - 40, 32, text2) end self.contents.font.size -= 4 if text3 != nil self.contents.draw_text(4 , 64, self.width - 40, 32, text3) end if text4 != nil self.contents.draw_text(4 , 96, self.width - 40, 32, text4) end self.contents.font.size += 4 end end #============================================================================== # ■ Scene_lvup #------------------------------------------------------------------------------ # 处理升级画面的类。 #============================================================================== class Scene_Lvup #-------------------------------------------------------------------------- # ● 初始化对像 # actor_index : 角色索引 # menu_index : 选项起始位置 #-------------------------------------------------------------------------- def initialize(actor_index = 0 , menu_index = 0) @actor_index = actor_index @menu_index = menu_index end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main s1 = "增加HP" s2 = "增加"+Vocab::atk s3 = "增加"+Vocab::def s4 = "增加"+Vocab::agi s5 = "增加"+Vocab::spi s6 = "确认加点" s7 = "重新分配" @command_window = Window_Command.new(128, [s1, s2, s3, s4, s5, s6, s7]) @command_window.index = @menu_index # 获取角色 @actor = $game_party.members[@actor_index] # 将角色的剩余点数带入 $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE] # 初始化临时量 $temp_atk = 0 $temp_def = 0 $temp_agi = 0 $temp_spi = 0 $temp_hp = 0 $temp_mp = 0 #========================================================================= # 特别提示:这些设置也可以使用小数,但是可能出现0值意外错误 # (各种编程语言都有这种意外),建议还是使用整数,正负不限 #========================================================================= # 每提升一次力量,提升多少附加能力 #========================================================================= @atk_hp = 2 # 每提升一次力量附加提升多少HP @atk_mp = 0 # 每提升一次力量附加提升多少MP @atk_def = 0 # 每提升一次力量附加提升多少防御 @atk_agi = 0 # 每提升一次力量附加提升多少速度 @atk_spi = 0 # 每提升一次力量附加提升多少魔力 @atk_atk = 1 # 每提升一次力量附加提升多少力量 #========================================================================= # 每提升一次防御,提升多少附加能力 #========================================================================= @def_hp = 2 # 每提升一次灵巧附加提升多少HP @def_mp = 2 # 每提升一次灵巧附加提升多少MP @def_atk = 0 # 每提升一次灵巧附加提升多少力量 @def_agi = 0 # 每提升一次灵巧附加提升多少速度 @def_spi = 0 # 每提升一次灵巧附加提升多少魔力 @def_def = 1 # 每提升一次灵巧附加提升多少防御 #========================================================================= # 每提升一次速度,提升多少附加能力 #========================================================================= @agi_hp = 1 # 每提升一次速度附加提升多少HP @agi_mp = 1 # 每提升一次速度附加提升多少MP @agi_atk = 0 # 每提升一次速度附加提升多少力量 @agi_def = 0 # 每提升一次速度附加提升多少防御 @agi_spi = 0 # 每提升一次速度附加提升多少魔力 @agi_agi = 1 # 每提升一次速度附加提升多少速度 #========================================================================= # 每提升一次魔力,提升多少附加能力 #========================================================================= @spi_hp = 0 # 每提升一次魔力附加提升多少HP @spi_mp = 5 # 每提升一次魔力附加提升多少MP @spi_atk = 0 # 每提升一次魔力附加提升多少力量 @spi_def = 0 # 每提升一次魔力附加提升多少防御 @spi_agi = 0 # 每提升一次魔力附加提升多少速度 @spi_spi = 1 # 每提升一次魔力附加提升多少魔力 #========================================================================= # 每提升一次体力,提升多少附加能力 #========================================================================= @hp = 10 # 每提升一次体力提升多少HP @mp = 1 # 每提升一次体力提升多少MP @hp_atk = 0 # 每提升一次体力提升多少力量 @hp_def = 0 # 每提升一次体力提升多少速度 @hp_agi = 0 # 每提升一次体力提升多少灵巧 @hp_spi = 0 # 每提升一次体力提升多少魔力 # 定义说明文字 @text_hp_sc = "体力可以增加生存的能力,可以延长生存的时间!" @text_atk_sc = Vocab::atk + "可以增加物理攻击和物理技能的威力!" @text_def_sc = Vocab::def + "可以提高物理防御能力!" @text_agi_sc = Vocab::agi + "可以提高回避、命中、逃跑成功率!" @text_spi_sc = Vocab::spi + "可以提高吟唱魔法的威力!" @text_save = "保存分配情况并返回游戏" @text_reset= "重新分配能力点数" @text_2 = "每增加一次此项能力值,可以提升能力值" @text_hp = "最大" + Vocab::hp + "值" @text_mp = "最大" + Vocab::mp + "值" @text_atk = "最大" + Vocab::atk + "值" @text_def = "最大" + Vocab::def + "值" @text_agi = "最大" + Vocab::agi + "值" @text_spi = "最大" + Vocab::spi + "值" s_disable # 生成状态窗口 @lvup_window = Window_Lvup.new(@actor) @lvup_window.x = 128 @lvup_window.y = 0 @lvpoint_window = Window_Lvpoint.new # 生成帮助窗口并初始化帮助文本 @help_window = Window_Lvup_Help.new # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果切换画面就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @lvpoint_window.dispose @command_window.dispose @lvup_window.dispose @help_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @command_window.update # 选项明暗判断(因为太消耗资源,所以屏蔽掉了) s_disable @lvup_window.update #============================================================= # 按下 B 键的情况下 #============================================================= if Input.trigger?(Input::B) # 演奏取消 SE Sound.play_cancel # 切换画面 $scene = Scene_Menu.new(5)#x是选项光标位置 从0开始算 return end #============================================================= # 按下 C 键的情况下 #============================================================= if Input.trigger?(Input::C) if @command_window.index == 5 # 演奏确定 SE Sound.play_decision # 将角色的剩余点数带回 $game_variables[@actor.id + LEVEL_UP_VARIABLE] = $point # 将角色点数实际加上 @actor.atk += $temp_atk @actor.def += $temp_def @actor.agi += $temp_agi @actor.spi += $temp_spi @actor.maxhp += $temp_hp @actor.maxmp += $temp_mp # 切换画面 $scene = Scene_Lvup.new(@actor_index , @command_window.index) return end if @command_window.index == 6 # 演奏确定 SE Sound.play_decision # 将角色的剩余点数带入 $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE] # 初始化临时量 $temp_atk = 0 $temp_def = 0 $temp_agi = 0 $temp_spi = 0 $temp_hp = 0 $temp_mp = 0 @lvup_window.refresh @lvpoint_window.refresh return end if $point == 0 # 演奏冻结 SE Sound.play_buzzer return end case @command_window.index when 0 # 演奏确定 SE Sound.play_decision $temp_hp += @hp $temp_mp += @mp $temp_atk += @hp_atk $temp_def += @hp_def $temp_agi += @hp_agi $temp_spi += @hp_spi $point -= 1 @lvup_window.refresh @lvpoint_window.refresh s_disable return when 1 # 演奏确定 SE Sound.play_decision $temp_atk += @atk_atk $temp_hp += @atk_hp $temp_mp += @atk_mp $temp_def += @atk_def $temp_agi += @atk_agi $temp_spi += @atk_spi $point -= 1 @lvup_window.refresh @lvpoint_window.refresh s_disable return when 2 # 演奏确定 SE Sound.play_decision $temp_def += @def_def $temp_hp += @def_hp $temp_mp += @def_mp $temp_atk += @def_atk $temp_agi += @def_agi $temp_spi += @def_spi $point -= 1 @lvup_window.refresh @lvpoint_window.refresh s_disable return when 3 # 演奏确定 SE Sound.play_decision $temp_agi += @agi_agi $temp_hp += @agi_hp $temp_mp += @agi_mp $temp_atk += @agi_atk $temp_def += @agi_def $temp_spi += @agi_spi $point -= 1 @lvup_window.refresh @lvpoint_window.refresh s_disable return when 4 # 演奏确定 SE Sound.play_decision $temp_spi += @spi_spi $temp_hp += @spi_hp $temp_mp += @spi_mp $temp_atk += @spi_atk $temp_def += @spi_def $temp_agi += @spi_agi $point -= 1 @lvup_window.refresh @lvpoint_window.refresh s_disable return end end #============================================================= # 什么都没有按下的情况 #============================================================= case @command_window.index when 0 # 增加体力 temptext1 = @text_hp + @hp.to_s + "点 " + @text_atk + @hp_atk.to_s + "点 " + @text_def + @hp_def.to_s + "点" temptext2 = @text_mp + @mp.to_s + "点 " + @text_agi + @hp_agi.to_s + "点 " + @text_spi + @hp_spi.to_s + "点" @help_window.lvup_text(@text_hp_sc , @text_2 , temptext1 , temptext2) when 1 # 增加力量 temptext1 = @text_hp + @atk_hp.to_s + "点 " + @text_atk + @atk_atk.to_s + "点 " + @text_def + @atk_def.to_s + "点" temptext2 = @text_mp + @atk_mp.to_s + "点 " + @text_agi + @atk_agi.to_s + "点 " + @text_spi + @atk_spi.to_s + "点" @help_window.lvup_text(@text_atk_sc , @text_2 , temptext1 , temptext2) when 2 # 增加防御 temptext1 = @text_hp + @def_hp.to_s + "点 " + @text_atk + @def_agi.to_s + "点 " + @text_def + @def_def.to_s + "点" temptext2 = @text_mp + @def_mp.to_s + "点 " + @text_agi + @def_agi.to_s + "点 " + @text_spi + @def_spi.to_s + "点" @help_window.lvup_text(@text_def_sc , @text_2 , temptext1 , temptext2) when 3 # 增加速度 temptext1 = @text_hp + @agi_hp.to_s + "点 " + @text_atk + @agi_atk.to_s + "点 " + @text_def + @agi_def.to_s + "点" temptext2 = @text_mp + @agi_mp.to_s + "点 " + @text_agi + @agi_agi.to_s + "点 " + @text_spi + @agi_spi.to_s + "点" @help_window.lvup_text(@text_agi_sc , @text_2 , temptext1 , temptext2) when 4 # 增加魔力 temptext1 = @text_hp + @spi_hp.to_s + "点 " + @text_atk + @spi_atk.to_s + "点 " + @text_def + @spi_def.to_s + "点" temptext2 = @text_mp + @spi_mp.to_s + "点 " + @text_agi + @spi_agi.to_s + "点 " + @text_spi + @spi_spi.to_s + "点" @help_window.lvup_text(@text_spi_sc , @text_2 , temptext1 , temptext2) when 5 # 保存设定 @help_window.lvup_text(@text_save) when 6 # 点数重置 @help_window.lvup_text(@text_reset) end #============================================================= # 按下R与L换人的情况 #============================================================= if Input.trigger?(Input::R) # 演奏光标 SE Sound.play_cursor # 移至下一位角色 @actor_index += 1 @actor_index %= $game_party.members.size # 切换到别的状态画面 $scene = Scene_Lvup.new(@actor_index , @command_window.index) return end # 按下 L 键的情况下 if Input.trigger?(Input::L) # 演奏光标 SE Sound.play_cursor # 移至上一位角色 @actor_index += $game_party.members.size - 1 @actor_index %= $game_party.members.size # 切换到别的状态画面 $scene = Scene_Lvup.new(@actor_index , @command_window.index) return end end #-------------------------------------------------------------------------- # ● 选项明暗判断 #-------------------------------------------------------------------------- def s_disable # 判断剩余点数是否为0,如果为0,那么增加选项表示为暗色 if $point == 0 enabled = false else enabled = true end @command_window.draw_item(0,enabled) @command_window.draw_item(1,enabled) @command_window.draw_item(2,enabled) @command_window.draw_item(3,enabled) @command_window.draw_item(4,enabled) end end |
另:因为LZ并未给出升级加点一类的脚本,所以有些细节问题无法修复,例如返回时的光标在哪行的问题,更改方式参见: http://rpg.blue/thread-302402-1-1.html 第三楼 |
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-18 05:23
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.