加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
传统RPG都是靠等级吃饭,怪和BOSS实力都是一定的,这种情况下,可能99级就扫遍天下,所以我尝试做一个浮动战斗数值
浮动的意思就是你等级高了,怪物的能力也跟着你的水平改变参数,所以哪怕初期就100血的史莱姆,可能后期你面对他会是一个1000血的劲敌
由于是想着修改的,可能效率啊什么的不完美,也希望大家能够帮助我修改这些代码
首先是在新代码窗口添加Game_Party、Game_Enemy、Game_Troop的三个新方法
class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● 获取我方实力浮动值 #-------------------------------------------------------------------------- def battle_times times = 1 t_max = 1 t_min = 999999 for i in 0..6 if i != 5 members.each do |party| t_max = [party.param(i),t_max].max t_min = [party.param(i),t_min].min end times = [t_max*1.00/t_min*1.00,times].max t_max = 1 t_min = 999999 end end return times end end class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 浮动每个敌人的实力(每个敌人是有个浮动上限,需在注释添加内容) #-------------------------------------------------------------------------- def float(times) temp = 0 self.note.each_line do |line| case line when /\<(?:max_times)[ ]*(\d+)\>/i val = $1.to_i/100.0 if(val<times) temp = param(0).to_f*(val-1) add_param(0,temp) temp = param(1).to_f*(val-1) add_param(1,temp) temp = param(2).to_f*(val-1) add_param(2,temp) temp = param(3).to_f*(val-1) add_param(3,temp) temp = param(4).to_f*(val-1) add_param(4,temp) temp = param(6).to_f*(val-1) add_param(6,temp) @hp = (@hp*val).to_i @mp = (@mp*val).to_i else temp = param(0).to_f*(times-1) add_param(0,temp) temp = param(1).to_f*(times-1) add_param(1,temp) temp = param(2).to_f*(times-1) add_param(2,temp) temp = param(3).to_f*(times-1) add_param(3,temp) temp = param(4).to_f*(times-1) add_param(4,temp) temp = param(6).to_f*(times-1) add_param(6,temp) end @hp = param(0) @mp = param(1) msgbox(@hp) end end end end class Game_Troop < Game_Unit #-------------------------------------------------------------------------- # ● 浮动生命 #-------------------------------------------------------------------------- def float_param(times) if times.to_i <= 0 return end members.each do |enemy| enemy.float(times) end end end
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 获取我方实力浮动值
#--------------------------------------------------------------------------
def battle_times
times = 1
t_max = 1
t_min = 999999
for i in 0..6
if i != 5
members.each do |party|
t_max = [party.param(i),t_max].max
t_min = [party.param(i),t_min].min
end
times = [t_max*1.00/t_min*1.00,times].max
t_max = 1
t_min = 999999
end
end
return times
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 浮动每个敌人的实力(每个敌人是有个浮动上限,需在注释添加内容)
#--------------------------------------------------------------------------
def float(times)
temp = 0
self.note.each_line do |line|
case line
when /\<(?:max_times)[ ]*(\d+)\>/i
val = $1.to_i/100.0
if(val<times)
temp = param(0).to_f*(val-1)
add_param(0,temp)
temp = param(1).to_f*(val-1)
add_param(1,temp)
temp = param(2).to_f*(val-1)
add_param(2,temp)
temp = param(3).to_f*(val-1)
add_param(3,temp)
temp = param(4).to_f*(val-1)
add_param(4,temp)
temp = param(6).to_f*(val-1)
add_param(6,temp)
@hp = (@hp*val).to_i
@mp = (@mp*val).to_i
else
temp = param(0).to_f*(times-1)
add_param(0,temp)
temp = param(1).to_f*(times-1)
add_param(1,temp)
temp = param(2).to_f*(times-1)
add_param(2,temp)
temp = param(3).to_f*(times-1)
add_param(3,temp)
temp = param(4).to_f*(times-1)
add_param(4,temp)
temp = param(6).to_f*(times-1)
add_param(6,temp)
end
@hp = param(0)
@mp = param(1)
msgbox(@hp)
end
end
end
end
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● 浮动生命
#--------------------------------------------------------------------------
def float_param(times)
if times.to_i <= 0
return
end
members.each do |enemy|
enemy.float(times)
end
end
end
而后,在BattleManager的self.battle_start中修改成下面的形式
def self.battle_start $game_system.battle_count += 1 $game_party.on_battle_start $game_troop.on_battle_start $game_troop.float_param($game_party.battle_times) $game_troop.enemy_names.each do |name| $game_message.add(sprintf(Vocab::Emerge, name)) end if @preemptive $game_message.add(sprintf(Vocab::Preemptive, $game_party.name)) elsif @surprise $game_message.add(sprintf(Vocab::Surprise, $game_party.name)) end wait_for_message end
def self.battle_start
$game_system.battle_count += 1
$game_party.on_battle_start
$game_troop.on_battle_start
$game_troop.float_param($game_party.battle_times)
$game_troop.enemy_names.each do |name|
$game_message.add(sprintf(Vocab::Emerge, name))
end
if @preemptive
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
elsif @surprise
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
end
wait_for_message
end
之后就是设定敌人的最大浮动数,如下图右侧的第一行(其他行是别的代码,无视之),125在代码中会除以100,所以敌人的浮动值是1.25:
可以看到这只老鼠的基础体力是75,现在看一下我们的队伍情况:
可以看到两个队员能形成的最大浮动是魔法攻击的2.0,但是敌人最大浮动是1.25,因此此时敌人的能力应当全部乘以1.25,我们来看一下战斗时,敌人的实际能力是多少:
这样就产生浮动了
以上是我自己摸索出来的浮动战斗方式,欢迎大家来批评指正,并提出更好的方法 |