闲来无事,搞了个角色转生系统。该系统仿照一些网游的角色转生,具体的介绍这里就不多说,看脚本里面。
建议下载下面的工程,工程里另外包括了个升级加点系统,已修改过,和这个角色转生系统相关联。
建议使用该系统时,配合使用升级加点脚本和突破能力值上线的脚本,打造高自由型RPG。
更新内容:1,加入角色的EXP基本值和增加度随转生的次数的增加而增加。
2,把角色转生后每升一级多增加的属性点,设为手动设置。
截图:
脚本:
- #==============================================================================# ★ 【角色转生系统】★#------------------------------------------------------------------------------# ☆ by 芯☆淡茹水 #==============================================================================#◆ 使用方法:# 复制该脚本,插入到 Main 前。# 召唤转生系统的方法:事件 → 脚本 写入 $scene = Scene_Lx.new#===============================================================================#◆ 说明:# 和一些网游的转生类似。角色随着转生次数的增加,各种属性(hp,sp,力量,# 灵巧,,,等)的初始值会越来越高,而每升一级增加的属性也会越来越多。# (注意:数据库各角色的初始等级都设置为 1 级。)## 由于手动设置的项目较多,在使用前,请先仔细阅读并设置下面的设置项。##==============================================================================#◆ 设置:#================]#------------------------------------------------------------------------------LX_LEVEL = 60 #达到转生要求的最低等级。#------------------------------------------------------------------------------LX_VARIABLE = 200 #储存各角色转生次数的起始变量。比如:设置为 200 ,那么1号角# 色转生次数储存在 201 号变量,2号角色储存在 202 号变量,,,#------------------------------------------------------------------------------LX_N = 10 #转生前,角色的各属性除以设定的这个值,再乘以转生次数,加入# 到转生后的属性中。这个设定的值越高,加入转生后的属性就越# 少,反之就越多。#------------------------------------------------------------------------------LX_DX = false #转生次数限制,限制写 true 不限制写 false#------------------------------------------------------------------------------LX_DX_N = 5 #转生最高次数限制,上面的限制设置写 true 该项才有效。#------------------------------------------------------------------------------LX_CLASS = false #转生后是否改变角色职业,是 写入 true 否 写入 false #------------------------------------------------------------------------------LX_CLASS_ID = 1 #转生后,角色的职业ID。上面是否改变职业设置写 true# 该设置才有效。# 比如转生后,全部转为 1 号职业,从“新手”做起。#------------------------------------------------------------------------------LX_EVENT_ID = 1 #转生成功后激活的公共事件ID。公共事件里可设置一些转生成功后# 播放动画,以及一些提示等。#------------------------------------------------------------------------------LEVEL_UP = false #推荐配合使用升级加点系统。如果工程里有升级加点系统# 请写 true 没有则写 false #==============================================================================##转生后角色各属性增加度设置:#------------------------------------------------------------------------------#(角色每升一级增加的属性 = 数据库设置的基本值 + 下面设置的增加度 乘以 转生次数)#(比如设置HP为 10 ,转生 0 次 角色每升一级,角色的HP多增加 0 点;# 转生 1 次 多增加 10 点;转生 2 次 多增加 20 点,,,,;以此类推。)#------------------------------------------------------------------------------LX_EXP = 2 # EXP曲线基础值和增加度。(一般设为 1 — 10)#------------------------------------------------------------------------------LX_HP = 10 # HP#------------------------------------------------------------------------------LX_SP = 8 # SP#------------------------------------------------------------------------------LX_STATE = 1 # 四项属性(力量,灵巧,速度,魔力)#==============================================================================################################################################################==============================================================================#★ 重新定义角色各属性#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 计算 EXP #-------------------------------------------------------------------------- def make_exp_list actor = $data_actors[@actor_id] lx = ($game_variables[@actor_id + LX_VARIABLE] + 1) * LX_EXP actor.exp_inflation += lx actor.exp_basis += lx @exp_list[1] = 0 pow_i = 2.4 + actor.exp_inflation / 100.0 for i in 2..100 if i > actor.final_level @exp_list[i] = 0 else n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i) @exp_list[i] = @exp_list[i-1] + Integer(n) end end end #-------------------------------------------------------------------------- # ● 获取基本 MaxHP #-------------------------------------------------------------------------- def base_maxhp lx = $game_variables[@actor_id + LX_VARIABLE] * @level return $data_actors[@actor_id].parameters[0, @level] + lx * LX_HP end #-------------------------------------------------------------------------- # ● 获取基本 MaxSP #-------------------------------------------------------------------------- def base_maxsp lx = $game_variables[@actor_id + LX_VARIABLE] * @level return $data_actors[@actor_id].parameters[1, @level] + lx * LX_SP end #-------------------------------------------------------------------------- # ● 获取基本力量 #-------------------------------------------------------------------------- def base_str lx = $game_variables[@actor_id + LX_VARIABLE] * @level n = $data_actors[@actor_id].parameters[2, @level] + lx * LX_STATE weapon = $data_weapons[@weapon_id] armor1 = $data_armors[@armor1_id] armor2 = $data_armors[@armor2_id] armor3 = $data_armors[@armor3_id] armor4 = $data_armors[@armor4_id] n += weapon != nil ? weapon.str_plus : 0 n += armor1 != nil ? armor1.str_plus : 0 n += armor2 != nil ? armor2.str_plus : 0 n += armor3 != nil ? armor3.str_plus : 0 n += armor4 != nil ? armor4.str_plus : 0 return [[n, 1].max, 999].min end #-------------------------------------------------------------------------- # ● 获取基本灵巧 #-------------------------------------------------------------------------- def base_dex lx = $game_variables[@actor_id + LX_VARIABLE] * @level n = $data_actors[@actor_id].parameters[3, @level] + lx * LX_STATE weapon = $data_weapons[@weapon_id] armor1 = $data_armors[@armor1_id] armor2 = $data_armors[@armor2_id] armor3 = $data_armors[@armor3_id] armor4 = $data_armors[@armor4_id] n += weapon != nil ? weapon.dex_plus : 0 n += armor1 != nil ? armor1.dex_plus : 0 n += armor2 != nil ? armor2.dex_plus : 0 n += armor3 != nil ? armor3.dex_plus : 0 n += armor4 != nil ? armor4.dex_plus : 0 return [[n, 1].max, 999].min end #-------------------------------------------------------------------------- # ● 获取基本速度 #-------------------------------------------------------------------------- def base_agi lx = $game_variables[@actor_id + LX_VARIABLE] * @level n = $data_actors[@actor_id].parameters[4, @level] + lx * LX_STATE weapon = $data_weapons[@weapon_id] armor1 = $data_armors[@armor1_id] armor2 = $data_armors[@armor2_id] armor3 = $data_armors[@armor3_id] armor4 = $data_armors[@armor4_id] n += weapon != nil ? weapon.agi_plus : 0 n += armor1 != nil ? armor1.agi_plus : 0 n += armor2 != nil ? armor2.agi_plus : 0 n += armor3 != nil ? armor3.agi_plus : 0 n += armor4 != nil ? armor4.agi_plus : 0 return [[n, 1].max, 999].min end #-------------------------------------------------------------------------- # ● 获取基本魔力 #-------------------------------------------------------------------------- def base_int lx = $game_variables[@actor_id + LX_VARIABLE] * @level n = $data_actors[@actor_id].parameters[5, @level] + lx * LX_STATE weapon = $data_weapons[@weapon_id] armor1 = $data_armors[@armor1_id] armor2 = $data_armors[@armor2_id] armor3 = $data_armors[@armor3_id] armor4 = $data_armors[@armor4_id] n += weapon != nil ? weapon.int_plus : 0 n += armor1 != nil ? armor1.int_plus : 0 n += armor2 != nil ? armor2.int_plus : 0 n += armor3 != nil ? armor3.int_plus : 0 n += armor4 != nil ? armor4.int_plus : 0 return [[n, 1].max, 999].min endend################################################################################==============================================================================#★ 转生场景#==============================================================================class Scene_Lx def main #选择窗口 @command_window = Window_LxCommand.new @command_window.visible = false #帮助窗口 @help_window = Window_LxHelp.new #状态窗口 @status_window = Window_LxStatus.new #背景窗口 @lxa_window = Window_LxBack.new @lxa_window.y = 64 @lxb_window = Window_LxBack.new @lxb_window.y = 168 @lxc_window = Window_LxBack.new @lxc_window.y = 272 @lxd_window = Window_LxBack.new @lxd_window.y = 376 #过渡 Graphics.transition #循环 loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze #释放窗口 @command_window.dispose @help_window.dispose @status_window.dispose @lxa_window.dispose @lxb_window.dispose @lxc_window.dispose @lxd_window.dispose end #刷新 def update @command_window.update @status_window.update @help_window.update if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) @status_window.active = true return end if @status_window.active update_status return end if @command_window.active update_command return end end #刷新(状态窗口) def update_status @help_window.refresh if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) level = $game_party.actors[@status_window.index].level #限制 if level >= LX_LEVEL if LX_DX == true i = $game_party.actors[@status_window.index].id if $game_variables[i + LX_VARIABLE] < LX_DX_N $game_system.se_play($data_system.decision_se) @status_window.active = false @command_window.visible = true @command_window.active = true @command_window.index = 0 else $game_system.se_play($data_system.buzzer_se) text = "已达转生次数上限!" @help_window.contents.clear @help_window.contents.draw_text(170,0, 246, 32, text) @status_window.active = false end else $game_system.se_play($data_system.decision_se) @status_window.active = false @command_window.visible = true @command_window.active = true @command_window.index = 0 end else $game_system.se_play($data_system.buzzer_se) text = LX_LEVEL.to_s text += "级后才能转生!" @help_window.contents.clear @help_window.contents.draw_text(190,0, 186, 32, text) @status_window.active = false end return end end #刷新(选择窗口) def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @status_window.active = true @command_window.visible = false @command_window.active = false @command_window.index = -1 return end if Input.trigger?(Input::C) case @command_window.index when 0 $game_system.se_play($data_system.decision_se) update_xdrs_lx when 1 $game_system.se_play($data_system.cancel_se) @status_window.active = true @command_window.visible = false @command_window.active = false @command_window.index = -1 end return end end #刷新(转生) def update_xdrs_lx #获取角色。 actor = $game_party.actors[@status_window.index] i = actor.id #获取储存角色转生次数的变量ID. v = LX_VARIABLE + i #代入角色转生前的各数据,并计算最终增加的属性。 n = $game_variables[v] + 1 hp = actor.maxhp/LX_N * n sp = actor.maxsp/LX_N * n str = actor.str/LX_N * n dex = actor.dex/LX_N * n agi = actor.agi/LX_N * n int = actor.int/LX_N * n #角色初始化。 $game_actors[i].setup(i) #确认转生后是否改变职业,是则变为设置的职业ID。 if LX_CLASS == true actor.class_id = LX_CLASS_ID end #加入角色转生后增加的各种属性。 actor.maxhp += hp actor.maxsp += sp actor.str += str actor.dex += dex actor.agi += agi actor.int += int #角色转生次数变量加 1 。 $game_variables[v] += 1 #回复。 actor.recover_all #确认升级加点系统,转生后,如果有剩余点数未加,将变为 0 。 #如果没有升级加点系统,跳过。 if LEVEL_UP == true va = LEVEL_UP_VARIABLE + i $game_variables[va] = 0 end #激活公共事件。 $game_temp.common_event_id = LX_EVENT_ID #切换到地图场景。 $scene = Scene_Map.new endend################################################################################==============================================================================#★ 增加描绘转生次数的定义#==============================================================================class Window_Base < Window def draw_actor_xdrs_lx(actor, x, y) self.contents.font.color = text_color(3) self.contents.draw_text(x + 4, y, 120, 32, "转生次数:") i = actor.id + LX_VARIABLE self.contents.font.color = text_color(6) self.contents.draw_text(x + 126, y, 80, 32, $game_variables[i].to_s) endend#===============================================================================#★ 帮助窗口#===============================================================================class Window_LxHelp < Window_Base def initialize super(0, 0, 640, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh self.contents.clear self.contents.draw_text(170, 0, 246, 32, "★请选择要转生的角色★") endend#===============================================================================#★ 选择窗口#===============================================================================class Window_LxCommand < Window_Selectable def initialize super(240, 180, 160, 124) self.contents = Bitmap.new(width - 32, height - 32) @item_max = 2 @commands = ["是", "否"] refresh self.z = 999 self.active = false self.index = -1 end def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end def draw_item(index) self.contents.font.color = system_color self.contents.draw_text(0, 0, 148, 32, "是否确定转生?") y = 30 + index * 32 self.contents.font.color = normal_color self.contents.draw_text(0, y, 126, 32, @commands[index]) end def update_cursor_rect self.cursor_rect.set(-5, 30 + index * 32, 134, 32) endend#===============================================================================#★ 角色状态 + 选择角色窗口#===============================================================================class Window_LxStatus < Window_Selectable def initialize super(0, 64, 640, 446) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 refresh self.index = 0 end def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = 5 y = i * 104 - 3 actor = $game_party.actors[i] draw_actor_xdrs_lx(actor, x + 130, y + 56) draw_actor_graphic(actor, x + 35, y + 80) draw_actor_name(actor, x, y) draw_actor_class(actor, x + 134, y + 28) draw_actor_level(actor, x + 134, y) draw_actor_exp(actor, x + 300, y + 56) draw_actor_hp(actor, x + 300, y ) draw_actor_sp(actor, x + 300, y + 26) end end def update_cursor_rect self.cursor_rect.set(- 12, @index * 104 - 12 , self.width - 4 , 96) endend#===============================================================================#★ 状态窗口背景#===============================================================================class Window_LxBack < Window_Base def initialize super(0, 0, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) endend#===============================================================================#★ 重新描绘其它状态窗口,增加描绘转生次数。#===============================================================================class Window_Status < Window_Base def refresh self.contents.clear draw_actor_graphic(@actor, 40, 112) draw_actor_name(@actor, 4, 0) draw_actor_class(@actor, 4 + 144, 0) draw_actor_level(@actor, 96, 32) draw_actor_state(@actor, 96, 64) draw_actor_hp(@actor, 96, 112, 172) draw_actor_sp(@actor, 96, 144, 172) draw_actor_parameter(@actor, 96, 192, 0) draw_actor_parameter(@actor, 96, 224, 1) draw_actor_parameter(@actor, 96, 256, 2) draw_actor_parameter(@actor, 96, 304, 3) draw_actor_parameter(@actor, 96, 336, 4) draw_actor_parameter(@actor, 96, 368, 5) draw_actor_parameter(@actor, 96, 400, 6) draw_actor_xdrs_lx(@actor, 315, 0) self.contents.font.color = system_color self.contents.draw_text(320, 48, 80, 32, "EXP") self.contents.draw_text(320, 80, 80, 32, "NEXT") self.contents.font.color = normal_color self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2) self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2) self.contents.font.color = system_color self.contents.draw_text(320, 160, 96, 32, "装备") draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208) draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256) draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304) draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352) draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400) end def dummy self.contents.font.color = system_color self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon) self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1) self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2) self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3) self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4) draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144) draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208) draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272) draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336) draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400) endend#==============================================================================class Window_MenuStatus < Window_Selectable def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size x = 64 y = i * 116 actor = $game_party.actors[i] draw_actor_graphic(actor, x - 40, y + 80) draw_actor_xdrs_lx(actor, 294, y) draw_actor_name(actor, x, y) draw_actor_class(actor, x + 144, y) draw_actor_level(actor, x, y + 32) draw_actor_state(actor, x + 90, y + 32) draw_actor_exp(actor, x, y + 64) draw_actor_hp(actor, x + 236, y + 32) draw_actor_sp(actor, x + 236, y + 64) end endend################################################################################复制代码
复制代码工程下载地址:
http://dl.vmall.com/c0mu52j00z
若有BUG,或不足之处,请留言。本人可改进。
本帖来自P1论坛作者芯☆淡茹水,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:
https://rpg.blue/forum.php?mod=viewthread&tid=284372 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。