if not c.turn_ending and not c.turn_valid and not c.enemy_valid and
not c.actor_valid and not c.switch_valid
return false # 未设置条件…不执行
end
if @event_flags
return false # 已执行
end
if c.enemy_valid # 敌方角色
enemy = $game_troop.members[c.enemy_index]
return false if enemy == nil
if c.turn_ending == false #
return false if enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
elsif c.turn_ending and not c.turn_valid
return false if enemy.Battler_turn != c.enemy_hp or enemy.cp != 100
elsif c.turn_ending and c.turn_valid
a = c.turn_a
b = c.turn_b
if b>0
return false if (a==0 and ( c.enemy_hp < 1 or enemy.Battler_turn < c.enemy_hp or enemy.Battler_turn % b != c.enemy_hp % b or enemy.cp != 100 or enemy.turn_start != 1))
return false if (a==1 and ( c.enemy_hp < 1 or enemy.Battler_turn < c.enemy_hp or enemy.Battler_turn % b != c.enemy_hp % b or enemy.cp != 100 or enemy.turn_start != 0))
else
if a == 0 #回合开始时 等于
return false if ( enemy.Battler_turn != c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
elsif a == 1 # #回合开始时 回合数大于
return false if (enemy.Battler_turn <= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
elsif a == 2 #回合开始时 回合数小于
return false if (enemy.Battler_turn >= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
elsif a == 3 #回合结束时 回合数等于
return false if (enemy.Battler_turn != c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
elsif a == 4 #回合结束时 回合数大于
return false if (enemy.Battler_turn <= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
elsif a == 5 # 回合结束时 回合数小于
return false if (enemy.Battler_turn >= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
end
end
end
end
if c.actor_valid # 角色
actor = $game_actors[c.actor_id]
return false if actor == nil
if c.turn_ending == false #
return false if actor.hp * 100.0 / actor.maxhp > c.actor_hp
elsif c.turn_ending and not c.turn_valid
return false if actor.Battler_turn != c.actor_hp or actor.cp != 100
elsif c.turn_ending and c.turn_valid
a = c.turn_a
b = c.turn_b
if b > 0
return false if (a== 0 and ( c.actor_hp < 1 or actor.Battler_turn < c.actor_hp or actor.Battler_turn % b != c.actor_hp % b or actor.cp != 100 or actor.turn_start != 1))
return false if (a== 1 and ( c.actor_hp < 1 or actor.Battler_turn < c.actor_hp or actor.Battler_turn % b != c.actor_hp % b or actor.cp != 100 or actor.turn_start != 0))
else
if a == 0 # 等于
return false if (actor.Battler_turn != c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
elsif a == 1 #回合开始时 回合数大于
return false if (actor.Battler_turn <= c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
elsif a == 2 #回合开始时 回合数小于
return false if (actor.Battler_turn >= c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
elsif a == 3 #回合结束时 回合数等于
return false if (actor.Battler_turn != c.actor_hp or actor.cp != 100 or actor.turn_start != 0)
elsif a == 4 #回合结束时 回合数大于
return false if (actor.Battler_turn <= c.actor_hp or actor.cp != 100 or actor.turn_start != 0)
elsif a == 5 #回合结束时 回合数小于
return false if (actor.Battler_turn >= c.actor_hp or actor.cp != 100 or actor.turn_start != 0)
end
end
end
end
if c.switch_valid # 开关
return false if $game_switches[c.switch_id] == false
@battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
break
else
if BATTLE_BACK[name] != nil
@battleback = Cache.battleback("#{BATTLE_BACK[name]}")if FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.bmp")
end
break
end
end
end
if @battleback == nil
name = $game_map.name
unless B_B_CONFIG
@battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
if FileTest.exist?("Graphics/Battlers/#{b_name}.png") or FileTest.exist?("Graphics/Battlers/#{b_name}.jpg") or FileTest.exist?("Graphics/Battlers/#{b_name}.bmp")
self.bitmap = Cache.battler(b_name,@battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width/2
self.oy = @height
end
end
end
#==================================
#
#==================================
def setup_new_effect
if @battler.white_flash
@effect_type = WHITEN
@effect_duration = 16
@battler.white_flash = false
end
if @battler.blink
@effect_type = BLINK
@effect_duration = 20
@battler.blink = false
end
if not @battler_visible and @battler.exist?
@effect_type = APPEAR
@effect_duration = 16
@battler_visible = true
end
if @battler.damage_pop and not (@battler.collapse or @battler.hidden)
alias oldinitialize initialize
def initialize
@cp = 0
@cp_total = false
@cp_turn = 0
@damage = nil
@damage_pop = false
@act_status = 0
@slip_damage = 0
@auto_damage = 0
@Battler_turn = 0
@turn_start = 0
oldinitialize
end
def maxcp
return 100
end
#--------------------------------------------------------------------------
# ● 应用连续伤害效果
#--------------------------------------------------------------------------
def slip_damage_effect
if slip_damage? and @hp > 0
@hp_damage = apply_variance(maxhp / 10, 10)
@hp_damage = @hp - 1 if @hp_damage >= @hp
@slip_damage = @hp_damage
self.hp -= @hp_damage
end
end
end #class
#===============================================
#★角色队伍类
#===============================================
class Game_Party < Game_Unit
attr_accessor :actor_battler
alias oldinitialize initialize
def initialize
oldinitialize
@actor_battler = []
end
end #class
#================================================
#★敌人队伍类
#================================================
class Game_Troop < Game_Unit
attr_accessor :enemy_battler
alias oldinitialize initialize
def initialize
oldinitialize
@enemy_battler = []
end
#--------------------------------------------------------------------------
# ● 判断是否符合战斗事件 (页) 条件
# page : 战斗事件页
#--------------------------------------------------------------------------
def conditions_met?(page)
c = page.condition
if not c.turn_ending and not c.turn_valid and not c.enemy_valid and
not c.actor_valid and not c.switch_valid
return false # 未设置条件…不执行
end
if @event_flags
return false # 已执行
end
if c.enemy_valid # 敌方角色
enemy = $game_troop.members[c.enemy_index]
return false if enemy == nil
if c.turn_ending == false #
return false if enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
elsif c.turn_ending and not c.turn_valid
return false if enemy.Battler_turn != c.enemy_hp or enemy.cp != 100
elsif c.turn_ending and c.turn_valid
a = c.turn_a
b = c.turn_b
if b>0
return false if (a==0 and ( c.enemy_hp < 1 or enemy.Battler_turn < c.enemy_hp or enemy.Battler_turn % b != c.enemy_hp % b or enemy.cp != 100 or enemy.turn_start != 1))
return false if (a==1 and ( c.enemy_hp < 1 or enemy.Battler_turn < c.enemy_hp or enemy.Battler_turn % b != c.enemy_hp % b or enemy.cp != 100 or enemy.turn_start != 0))
else
if a == 0 #回合开始时 等于
return false if ( enemy.Battler_turn != c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
elsif a == 1 # #回合开始时 回合数大于
return false if (enemy.Battler_turn <= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
elsif a == 2 #回合开始时 回合数小于
return false if (enemy.Battler_turn >= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
elsif a == 3 #回合结束时 回合数等于
return false if (enemy.Battler_turn != c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
elsif a == 4 #回合结束时 回合数大于
return false if (enemy.Battler_turn <= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
elsif a == 5 # 回合结束时 回合数小于
return false if (enemy.Battler_turn >= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
end
end
end
end
if c.actor_valid # 角色
actor = $game_actors[c.actor_id]
return false if actor == nil
if c.turn_ending == false #
return false if actor.hp * 100.0 / actor.maxhp > c.actor_hp
elsif c.turn_ending and not c.turn_valid
return false if actor.Battler_turn != c.actor_hp or actor.cp != 100
elsif c.turn_ending and c.turn_valid
a = c.turn_a
b = c.turn_b
if b > 0
return false if (a== 0 and ( c.actor_hp < 1 or actor.Battler_turn < c.actor_hp or actor.Battler_turn % b != c.actor_hp % b or actor.cp != 100 or actor.turn_start != 1))
return false if (a== 1 and ( c.actor_hp < 1 or actor.Battler_turn < c.actor_hp or actor.Battler_turn % b != c.actor_hp % b or actor.cp != 100 or actor.turn_start != 0))
else
if a == 0 # 等于
return false if (actor.Battler_turn != c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
elsif a == 1 #回合开始时 回合数大于
return false if (actor.Battler_turn <= c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
elsif a == 2 #回合开始时 回合数小于
return false if (actor.Battler_turn >= c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
elsif a == 3 #回合结束时 回合数等于
return false if (actor.Battler_turn != c.actor_hp or actor.cp != 100 or actor.turn_start != 0)
elsif a == 4 #回合结束时 回合数大于
return false if (actor.Battler_turn <= c.actor_hp or actor.cp != 100 or actor.turn_start != 0)
elsif a == 5 #回合结束时 回合数小于
return false if (actor.Battler_turn >= c.actor_hp or actor.cp != 100 or actor.turn_start != 0)
end
end
end
end
if c.switch_valid # 开关
return false if $game_switches[c.switch_id] == false
end
return true # 符合条件
end
#--------------------------------------------------------------------------
# ● 增加回合
#--------------------------------------------------------------------------
def increase_turn
for page in troop.pages
if page.span == 1
@event_flags= false
end
end
#@turn_count += 1
end
end
n = battler.character_index
rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
@cp_battler[battler].bitmap = Bitmap.new(cw,ch)
end
@cp_battler[battler].bitmap.blt(0, 0,bitmap,rect)
else
name = battler.original_name + "_敌人cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
else
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
end
@cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
end
@cp_battler[battler].z = 101
@cp_battler[battler].visible = false
end
end
#===========================================
#===========================================
def update
return if @stop
for battler in $game_party.members + $game_troop.members
if (@cp_battler[battler].disposed? or @cp_battler[battler].opacity == 0) and battler.dead?
@cp_battler.delete(@cp_battler[battler])
next
end
if battler.dead?
if @cp_battler.include?(battler)
@cp_battler[battler].collapse = true
end
battler.cp = 0
next
end
next if @cp_battler[battler].disposed?
battler.cp = [[battler.cp + BATTLE_SPEED*10*battler.agi / @all_agi,0].max,battler.maxcp].min if battler.movable?
battler.cp_turn = [[battler.cp_turn+BATTLE_SPEED*10*battler.agi / @all_agi, 0].max,battler.maxcp].min
if battler.cp == battler.maxcp
#============================
#☆设置战斗者处于回合准备状态
#============================
battler.turn_start = 3
#============================
if battler.is_a?(Game_Actor)
name = battler.id.to_s + "_a_cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
bitmap = Bitmap.new("Graphics/system/#{name}")
rect = bitmap.rect
@cp_battler[battler].bitmap = bitmap
else
bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
sign = battler.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = battler.character_index
rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
@cp_battler[battler].bitmap = Bitmap.new(cw,ch)
end
@cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
else
name = battler.original_name + "_a_cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
else
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/a_敌人cp")
end
@cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
end
@cp_battler[battler].z = 101
battler.cp_total = true
elsif battler.cp_total == true
if battler.is_a?(Game_Actor)
name = battler.id.to_s + "_cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
bitmap = Bitmap.new("Graphics/system/#{name}")
rect = bitmap.rect
@cp_battler[battler].bitmap = bitmap
else
bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
sign = battler.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = battler.character_index
rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
@cp_battler[battler].bitmap = Bitmap.new(cw,ch)
end
@cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
elsif
name = battler.original_name + "_敌人cp"
if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
@cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
@cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
end
battler.cp_total = false
@cp_battler[battler].z = 105
end
@cp_battler[battler].visible = true if @cp_battler[battler].visible == false
@cp_battler[battler].opacity = 255
@cp_battler[battler].y = 30
@cp_battler[battler].x = 95+300*battler.cp/battler.maxcp
if battler.cp_turn == battler.maxcp
battler.remove_states_auto unless battler.movable?
battler.slip_damage_effect
battler.do_auto_recovery if battler.is_a?(Game_Actor)
battler.damage_pop = true if battler.slip_damage != 0 or battler.auto_damage != 0
battler.cp_turn = 0
end
if battler.cp == battler.maxcp
if battler.is_a?(Game_Actor)
$game_party.actor_battler.push(battler)
else
battler.make_action
$game_troop.enemy_battler.push(battler)
battler.make_action
end
else
next
end
end
end
def dispose
for j in 0..25
@cpline.opacity -= 10
for i in @cp_battler.values
unless i.disposed?
i.opacity -= 10
end
end
Graphics.update
end
@v.dispose
@cpline.dispose
for i in @cp_battler.values
i.dispose unless i.disposed?
end
end
end
class Sprite_cpbattler < Sprite
attr_accessor :collapse
def initialize (viewport = nil)
super (viewport)
@effect_duration = 0
@collapse = false
end
def update
super
if self.collapse == true and self.opacity != 0
@effect_type = 5
@effect_duration = 48
self.color.set(255, 128, 128, 128)
for i in 0..48
self.opacity = 256 - (48 - @effect_duration) * 6
if self.opacity == 0
break
end
Graphics.update
@effect_duration -= 1
end
self.collapse = false
self.color.set(255,255,255,5)
end
end
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
end
#==========================================================================
#
#==========================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
#======================
@select_input = true
#======================
$game_temp.in_battle = true
#=============================================
unless $BTEST
@battleback = nil
for area in $data_areas.values
if $game_player.in_area?(area)
name = area.name
unless B_B_CONFIG
@battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
break
else
if BATTLE_BACK[name] != nil
@battleback = Cache.battleback("#{BATTLE_BACK[name]}")if FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.bmp")
end
break
end
end
end
if @battleback == nil
name = $game_map.name
unless B_B_CONFIG
@battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
else
if BATTLE_BACK[name] != nil
@battleback = Cache.battleback("#{BATTLE_BACK[name]}")
else
@battleback = nil
end
end
end
$game_temp.background_bitmap = @battleback if @battleback != nil
end
#==================================================
@spriteset = Spriteset_Battle.new
@message_window = Window_BattleMessage.new
@message_window.visible = false
@action_battlers = []
@cp_battle = Scene_CP.new
@cp_battle.stop = false
create_info_viewport
end
#--------------------------------------------------------------------------
# ● 战斗事件处理
#--------------------------------------------------------------------------
def process_battle_event
#============================
if $game_message.texts != nil
@message_window.visible = true
end
#=============================
loop do
return if judge_win_loss
return if $game_temp.next_scene != nil
$game_troop.interpreter.update
$game_troop.setup_battle_event
# wait_for_message
process_action if $game_troop.forcing_battler != nil
#======================================
unless $game_troop.interpreter.running?
if $game_message.texts != nil
@message_window.clear
@message_window.visible = false
end
return
end
#=======================================
update_basic
end
end
@actor_index += 1
index = 0
for battler in $game_party.members
if battler == @actor_battler[@actor_index]
break
else
index += 1
end
end
@status_window.index = index
if @active_battler != nil and @active_battler != @actor_battler[@actor_index] and @active_battler.is_a?(Game_Actor)
@active_battler.act_status = -1
end
@active_battler = @actor_battler[@actor_index]
@active_battler.act_status = 1
#=================================
#★角色回合事件处理
#================================
@active_battler.Battler_turn += 1
@active_battler.turn_start = 1
$game_troop.increase_turn
process_battle_event
if @active_battler.auto_battle
@active_battler.make_action
next
end
break if @active_battler.inputable?
end
start_actor_command_selection
end
if @actor_command_window.index == 0
@actor_command_window.active = true
end
end
#=======================================================
#★敌人选择刷新
#=======================================================
def update_target_enemy_selection
@target_enemy_window.update
select_icon_update(true)
if Input.trigger?(Input::B)
Sound.play_cancel
if @skill_window != nil
@skill_window.visible = true
end
if @item_window != nil
@item_window.visible = true
end
end_target_enemy_selection
elsif Input.trigger?(Input::C)
Sound.play_decision
@active_battler.action.target_index = @target_enemy_window.enemy.index
end_target_enemy_selection
end_skill_selection
end_item_selection
next_actor
# @active_battler.cp = 0
end
end
end_target_actor_selection
end_skill_selection
end_item_selection
next_actor
# @active_battler.cp = 0
end
end
#============================================
#★特技使用决定 处理
#===========================================
def determine_skill
@active_battler.action.set_skill(@skill.id)
@skill_window.active = false
if @skill.need_selection?
if @skill.for_opponent?
start_target_enemy_selection
else
start_target_actor_selection
end
else
end_skill_selection
next_actor
# @active_battler.cp = 0
end
end
#=========================================
#★物品使用决定 处理
#=========================================
def determine_item
@active_battler.action.set_item(@item.id)
@item_window.active = false
if @item.need_selection?
if @item.for_opponent?
start_target_enemy_selection
else
start_target_actor_selection
end
else
end_item_selection
next_actor
# @active_battler.cp = 0
end
end
end
#================================================
#★视口释放
#================================================
def dispose_info_viewport
@status_window.dispose
@actor_command_window.dispose
@info_viewport.dispose
#========================
#☆减少头像刷新用
#========================
@now_face = -1
if @window_egi != nil
@window_egi.dispose
end
end
#======================================================
#★视口刷新
#======================================================
def update_info_viewport
@actor_command_window.update
if @active_battler != nil and @active_battler.is_a?(Game_Actor) and @active_battler.id != @now_face
@status_window.draw_actorface(@active_battler)
@now_face = @active_battler.id
end
@status_window.update
if @actor_command_window.active and @actor_command_window.y > 0
@actor_command_window.y -= 8
@status_window.y -= 8
if $game_troop.preemptive
success = true
else
success = (rand(100) < @escape_ratio)
end
Sound.play_escape
if success
#=============================
@cp_battle.dispose
#=============================
for battler in $game_party.members
battler.cp = 0
#=========================
battler.Battler_turn = 0
battler.turn_start = 0
#=========================
end
battle_end(1)
else
@escape_ratio += 10
#@active_battler.cp = 0
@active_battler.action.clear
next_actor
end
end
#========================================
#★胜利处理
#========================================
def process_victory
@message_window.visible = false
@info_viewport.visible = false
RPG::BGM.stop
$game_system.battle_end_me.play
for battler in $game_troop.members
if battler.dead?
if @cp_battle.cp_battler.include?(battler)
@cp_battle.cp_battler[battler].collapse = true
next
end
end
end
@cp_battle.cp_battler.each{|key,value|
if value.disposed?
@cp_battler.delete(key)
next
end
value.update}
#=============================
@cp_battle.dispose
#=============================
for battler in $game_party.members
#=========================
battler.Battler_turn = 0
battler.turn_start = 0
#=========================
battler.cp = 0
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
display_exp_and_gold
display_drop_items
display_level_up
battle_end(0)
end
#=================================
#★失败处理
#=================================
def process_defeat
@message_window.visible = false
@cp_battle.dispose
for battler in $game_party.members + $game_troop.members
#=========================
battler.Battler_turn = 0
battler.turn_start = 0
#=========================
battler.cp = 0
end
@info_viewport.visible = false
battle_end(2)
end
#=====================================
# ★ 执行画面转换
#=====================================
def update_scene_change
case $game_temp.next_scene
when "map"
dispose_cp_battle
call_map
when "gameover"
dispose_cp_battle
call_gameover
when "title"
dispose_cp_battle
call_title
else
$game_temp.next_scene = nil
end
end
#=============================================================================
#★CP战斗的主要刷新★
#=============================================================================
while @action_battlers.size != 0 and judge_win_loss == false
process_action
#process_battle_event
end
@cp_battle.stop = false
#=============================
end
#=====================================
#★行动顺序生成
#=====================================
def make_action_orders
@action_battlers = []
unless $game_troop.surprise
@action_battlers += @actor_battler if @actor_battler.size != 0
end
unless $game_troop.preemptive
@action_battlers += @enemy_battler if @enemy_battler.size != 0
end
for battler in @action_battlers
battler.action.make_speed
end
@action_battlers.sort! do |a,b|
b.action.speed - a.action.speed
end
end
#====================================
#★战斗行动处理
#====================================
def process_action
return if judge_win_loss
return if $game_temp.next_scene != nil
set_next_active_battler
return if @active_battler == nil
return if @active_battler.dead?
user = @active_battler.action.skill_user
if skill.animation2_id != 0
display_animation(user,skill.animation2_id)
end
display_animation(targets, skill.animation_id)
wait_for_animation
@active_battler.mp -= @active_battler.calc_mp_cost(skill)
$game_temp.common_event_id = skill.common_event_id
for target in targets
target.skill_effect(@active_battler, skill)
display_action_effects(target, skill)
end
#=====================
#@active_battler.cp = 0
#=====================
end
end
alias oldstart_item_selection start_item_selection
def start_item_selection
oldstart_item_selection
@item_window.z=3000
@item_window.help_window.z = 3000
end
#=================================
#★刷新
#=================================
def update
super
if @battler == nil
self.bitmap = nil
else
@use_sprite = @battler.use_sprite?
if @use_sprite
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
update_battler_bitmap
if @battler.act_status == 1
if self.opacity <280
self.opacity += 20
end
elsif @battler.act_status == -1
if self.opacity > 125
self.opacity -= 20
end
elsif (@battler.dead? or @battler.hidden) and @battler.collapse == false
else
self.opacity = 255
end
end
setup_new_effect
update_effect
end
end
#===============================
#
#===============================
def update_battler_bitmap
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
if (@battler.dead? or @battler.hidden) and @battler.collapse == false
end
end
if @battler.is_a?(Game_Actor)
count = 40
else
count = 44
end
if Graphics.frame_count%count <= 19
self.bitmap = Cache.battler(@battler_name,@battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
else
b_name = @battler_name + "待"
if FileTest.exist?("Graphics/Battlers/#{b_name}.png") or FileTest.exist?("Graphics/Battlers/#{b_name}.jpg") or FileTest.exist?("Graphics/Battlers/#{b_name}.bmp")
self.bitmap = Cache.battler(b_name,@battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width/2
self.oy = @height
end
end
end
#==================================
#
#==================================
def setup_new_effect
if @battler.white_flash
@effect_type = WHITEN
@effect_duration = 16
@battler.white_flash = false
end
if @battler.blink
@effect_type = BLINK
@effect_duration = 20
@battler.blink = false
end
if not @battler_visible and @battler.exist?
@effect_type = APPEAR
@effect_duration = 16
@battler_visible = true
end
if @battler.damage_pop and not (@battler.collapse or @battler.hidden)
if @battler.damage != nil
s_1 = @battler.damage > 0 ? 0 : 1
@battler.damage = @battler.damage > 0 ? [email protected] : @battler.damage
end
damage(@battler.damage,@battler.critical,s_1) if @battler.damage != 0 and @battler.damage != nil
damage(@battler.hp_damage,@battler.critical,0) if @battler.hp_damage != 0
damage(@battler.mp_damage,@battler.critical,1) if @battler.mp_damage != 0
damage("失误",@battler.critical) if @battler.missed
damage("MISS",@battler.critical) if @battler.evaded
damage(@battler.slip_damage - @battler.auto_damage,@battler.critical) if @battler.slip_damage != 0 or @battler.auto_damage != 0
@battler.slip_damage = 0
@battler.auto_damage = 0
@battler.damage = nil
@battler.damage_pop = false
end
if @battler_visible and @battler.hidden
@effect_type = DISAPPEAR
@effect_duration = 32
@battler_visible = false
end
if @battler.collapse and self.opacity != 0
@effect_type = COLLAPSE
@effect_duration = 48
@battler.collapse = false
@battler_visible = false
end
if @battler.animation_id != 0 and @battler.collapse == false
self.opacity = 255
animation = $data_animations[@battler.animation_id]
mirror = @battler.animation_mirror
start_animation(animation, mirror)
@battler.animation_id = 0
end
end
#=========================================
#
#=========================================
end #class
#=================================================
#★处理战斗行动的类
#=================================================
class Game_BattleAction
#==========================================================================
#==========================================================================
#==========================================================================
#★定义角色战斗图 X 坐标
#==========================================================================
def screen_x
if self.index != nil
case index
when 0
return 460
when 1
return 440
when 2
return 420
when 3
return 400
end
else
return 0
end
end
#========================================================================
#★定义角色战斗图 Y 坐标
#========================================================================
def screen_y
if self.index != nil
case index
when 0
return 245
when 1
return 215
when 2
return 185
when 3
return 155
end
else
return 230
end
end
#========================================================================
#★定义角色战斗图 Z 坐标
#========================================================================
def screen_z
if self.index != nil
return 4 - self.index
else
return 0
end
end
def use_sprite?
return true
end
end#class
#==========================================================
#★模块定义
#==========================================================
module RPG
class BaseItem
def animation2_id
return @note != nil ? @note.to_i : 0
end
end
class Enemy
def animation1_id
animation1_id = @note.split(/,/)[0]
return animation1_id != nil ? animation1_id.to_i : 0
end
def animation2_id
animation2_id = @note.split(/,/)[1]
return animation2_id != nil ? animation2_id.to_i : 0
end
end
if @item_name[itn.name]==nil
@item_name[itn.name]=[0,""]
@item_name[itn.name][1]=itn.icon_index
m+=1
end
@item_name[itn.name][0] += 1
end
end
if @gold>0
m+=1
end
super(200,100, 160,32*m+112 )
self.opacity = 150
class Game_Interpreter
#===========================================================================
#☆角色显示动画方法
#○range:动画影响范围,-1全体或相应角色id
#●anim_id:动画id
#===========================================================================
def add_aa(range,anim_id)
iterate_battler(1,range) do |battler|
next unless battler.exist?
battler.animation_id = anim_id
end
#==============================================================================
# ■ Game_Equip 自定义装备模块
#==============================================================================
module Game_Equip
#--------------------------------------------------------------------------
# ● 物品(装备)重生
# item: 物品
# *gift: 附加属性(留空表示无属性,数字表示指定数量随机属性)
#--------------------------------------------------------------------------
def self.reini(item, *gift)
return if item.nil?
result = item.clone
gifts = *gift
gifts.flatten! if gifts.is_a? Array
## 附加属性为空或指定为(0)时,直接返回母版
return self.result(result) if gifts.nil? or gifts == 0
## 指定附加属性数量时
if gifts.is_a? Integer
## 控制数量
num = [gifts, GiftMax].min
gifts = []
## 随机生成指定数量的附加属性
rd = different_rand(Gifts.size-1, num)
rd.each{|n| gifts.push Game_Gift.new(n)}
end
gifts = [gifts].flatten
return self.result(result) if gifts.empty?
## 处理数据
result.gifts = gifts
name = ""
price = 0
for gift in gifts
name += gift.name
price += gift.weight * GiftPrice
end
## 设定名称
result.name = name + '的' + result.name
## 设定价格
result.price += price.round
## 设定颜色
result.text_color = gifts.size
return self.result(result)
end
#--------------------------------------------------------------------------
# ● 返回结果
# item: 物品
#--------------------------------------------------------------------------
def self.result(item)
case item
when RPG::Item
when RPG::Weapon
item.base_id = item.id
item.id = $data_weapons.size
$data_weapons << item
when RPG::Armor
item.base_id = item.id
item.id = $data_armors.size
$data_armors << item
end
return item
end
#--------------------------------------------------------------------------
# ● 物品(装备)重生
# item_id: 物品id
# type: 类型
# *gift: 附加属性(留空表示无属性,数字表示指定数量随机属性)
#--------------------------------------------------------------------------
def self.reini_id(item_id, type, *gift)
## 排除装备id为零的情况
return 0 if item_id == 0
case type
when 0
item = $base_weapons[item_id]
when 1
item = $base_armors[item_id]
end
return self.reini(item, *gift).id
end
end
#==============================================================================
# ■ Game_Gift 装备附加能力
#==============================================================================
class Game_Gift
include Game_Equip
#--------------------------------------------------------------------------
# ● 读取口
#--------------------------------------------------------------------------
attr_reader :type
attr_reader :value
attr_reader :name
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(type = nil, value = nil)
get_type(type)
get_value(value)
get_name
end
#--------------------------------------------------------------------------
# ● 获取属性
#--------------------------------------------------------------------------
def get_type(type)
unless type.nil? or type > Gifts.size or type < 0
@type = type
else
@type = rand(Gifts.size - 1)
end
end
#--------------------------------------------------------------------------
# ● 获取品质值
#--------------------------------------------------------------------------
def get_value(value)
unless value.nil? or value.abs > max
@value = value
else
@value = linear_rand(max) + 1
end
end
#--------------------------------------------------------------------------
# ● 获取名称
#--------------------------------------------------------------------------
def get_name
names = Gifts[@type].name.split(/,/)
n = (@value.abs-1)/(max.to_f/names.size)
@name = names[n.truncate]
end
#--------------------------------------------------------------------------
# ● 获取最大值
#--------------------------------------------------------------------------
def max
return Gifts[@type].max
end
#--------------------------------------------------------------------------
# ● 获取权重
#--------------------------------------------------------------------------
def weight
return @value > 0 ? @value / max.to_f * Gifts[@type].weight : 0
end
#--------------------------------------------------------------------------
# ● 获取是否百分比
#--------------------------------------------------------------------------
def percent
return Gifts[@type].percent
end
#--------------------------------------------------------------------------
# ● 攻击力
#--------------------------------------------------------------------------
def atk(actor_id)
# 无角色信息时返回
return 0 unless actor_id
# 数据类型不符时返回
return 0 if @type != 0 and @type != 1
if percent
return $game_actors[actor_id].self_atk * @value / 100
else
return @value
end
end
#--------------------------------------------------------------------------
# ● 防御力
#--------------------------------------------------------------------------
def def(actor_id)
# 无角色信息时返回
return 0 unless actor_id
# 数据类型不符时返回
return 0 if @type != 2 and @type != 3
if percent
return $game_actors[actor_id].self_def * @value / 100
else
return @value
end
end
#--------------------------------------------------------------------------
# ● 精神
#--------------------------------------------------------------------------
def spi(actor_id)
# 无角色信息时返回
return 0 unless actor_id
# 数据类型不符时返回
return 0 if @type != 4 and @type != 5
if percent
return $game_actors[actor_id].self_spi * @value / 100
else
return @value
end
end
#--------------------------------------------------------------------------
# ● 敏捷
#--------------------------------------------------------------------------
def agi(actor_id)
# 无角色信息时返回
return 0 unless actor_id
# 数据类型不符时返回
return 0 if @type != 6 and @type != 7
if percent
return $game_actors[actor_id].self_agi * @value / 100
else
return @value
end
end
#--------------------------------------------------------------------------
# ● hp
#--------------------------------------------------------------------------
def hp(actor_id)
# 无角色信息时返回
return 0 unless actor_id
# 数据类型不符时返回
return 0 if @type != 8 and @type != 9
if percent
return $game_actors[actor_id].self_maxhp * @value / 100
else
return @value
end
end
#--------------------------------------------------------------------------
# ● mp
#--------------------------------------------------------------------------
def mp(actor_id)
# 无角色信息时返回
return 0 unless actor_id
# 数据类型不符时返回
return 0 if @type != 10 and @type != 11
if percent
return $game_actors[actor_id].self_maxmp * @value / 100
else
return @value
end
end
#--------------------------------------------------------------------------
# ● 命中
#--------------------------------------------------------------------------
def hit
# 数据类型不符时返回
return 0 if @type != 12
return @value
end
#--------------------------------------------------------------------------
# ● 闪避
#--------------------------------------------------------------------------
def eva
# 数据类型不符时返回
return 0 if @type != 13
return @value
end
#--------------------------------------------------------------------------
# ● 暴击
#--------------------------------------------------------------------------
def cri
# 数据类型不符时返回
return 0 if @type != 14
return @value
end
#--------------------------------------------------------------------------
# ● 经验(百分比)
#--------------------------------------------------------------------------
def exp
# 数据类型不符时返回
return 0 if @type != 15
return @value
end
#--------------------------------------------------------------------------
# ● 高级装备暴率(百分比)
#--------------------------------------------------------------------------
def equip_chance
# 数据类型不符时返回
return 0 if @type != 16
return @value
end
end
#==============================================================================
# ■ RPG::BaseItem
#==============================================================================
module RPG
class BaseItem
## 颜色
attr_accessor :text_color
end
end
#==============================================================================
# ■ RPG::Weapon
#==============================================================================
module RPG
class Weapon < BaseItem
#------------------------------------------------------------------------
# 附加属性
#------------------------------------------------------------------------
attr_accessor :base_id
attr_accessor :actor_id
attr_accessor :gifts
#------------------------------------------------------------------------
# 攻击力(合)
#------------------------------------------------------------------------
def atk
n = @atk
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.atk(actor_id) end
return n
end
#------------------------------------------------------------------------
# 防御力(合)
#------------------------------------------------------------------------
def def
n = @def
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.def(actor_id) end
return n
end
#------------------------------------------------------------------------
# 魔力(合)
#------------------------------------------------------------------------
def spi
n = @spi
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.spi(actor_id) end
return n
end
#------------------------------------------------------------------------
# 敏捷(合)
#------------------------------------------------------------------------
def agi
n = @agi
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.agi(actor_id) end
return n
end
#------------------------------------------------------------------------
# 最大hp(合)
#------------------------------------------------------------------------
def maxhp
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.maxhp(actor_id) end
return n
end
#------------------------------------------------------------------------
# 最大mp(合)
#------------------------------------------------------------------------
def maxmp
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.maxmp(actor_id) end
return n
end
#------------------------------------------------------------------------
# 命中率(合)
#------------------------------------------------------------------------
def hit
n = @hit
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.hit end
return n
end
#------------------------------------------------------------------------
# 闪避率(合)
#------------------------------------------------------------------------
def eva
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.eva end
return n
end
#------------------------------------------------------------------------
# 暴击率(合)
#------------------------------------------------------------------------
def cri
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.cri end
return n
end
#--------------------------------------------------------------------------
# ● 经验(百分比)
#--------------------------------------------------------------------------
def exp
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.exp end
return n
end
#--------------------------------------------------------------------------
# ● 高级装备暴率(百分比)
#--------------------------------------------------------------------------
def equip_chance
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.equip_chance end
return n
end
end
end
#==============================================================================
# ■ RPG::Armor
#==============================================================================
module RPG
class Armor < BaseItem
#------------------------------------------------------------------------
# 附加属性
#------------------------------------------------------------------------
attr_accessor :base_id
attr_accessor :actor_id
attr_accessor :gifts
#------------------------------------------------------------------------
# 攻击力(合)
#------------------------------------------------------------------------
def atk
n = @atk
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.atk(actor_id) end
return n
end
#------------------------------------------------------------------------
# 防御力(合)
#------------------------------------------------------------------------
def def
n = @def
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.def(actor_id) end
return n
end
#------------------------------------------------------------------------
# 魔力(合)
#------------------------------------------------------------------------
def spi
n = @spi
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.spi(actor_id) end
return n
end
#------------------------------------------------------------------------
# 敏捷(合)
#------------------------------------------------------------------------
def agi
n = @agi
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.agi(actor_id) end
return n
end
#------------------------------------------------------------------------
# 最大hp(合)
#------------------------------------------------------------------------
def maxhp
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.maxhp(actor_id) end
return n
end
#------------------------------------------------------------------------
# 最大mp(合)
#------------------------------------------------------------------------
def maxmp
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.maxmp(actor_id) end
return n
end
#------------------------------------------------------------------------
# 命中率(合)
#------------------------------------------------------------------------
def hit
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.hit end
return n
end
#------------------------------------------------------------------------
# 闪避率(合)
#------------------------------------------------------------------------
def eva
n = @eva
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.eva end
return n
end
#------------------------------------------------------------------------
# 暴击率(合)
#------------------------------------------------------------------------
def cri
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.cri end
return n
end
#--------------------------------------------------------------------------
# ● 经验(百分比)
#--------------------------------------------------------------------------
def exp
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.exp end
return n
end
#--------------------------------------------------------------------------
# ● 高级装备暴率(百分比)
#--------------------------------------------------------------------------
def equip_chance
n = 0
@gifts = [] if @gifts.nil?
for g in @gifts.compact do n += g.equip_chance end
return n
end
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 获取自身 MaxHP
#--------------------------------------------------------------------------
def self_maxhp
return actor.parameters[0, @level]
end
#--------------------------------------------------------------------------
# ● 获取自身 MaxMP
#--------------------------------------------------------------------------
def self_maxmp
return actor.parameters[1, @level]
end
#--------------------------------------------------------------------------
# ● 获取自身攻击力
#--------------------------------------------------------------------------
def self_atk
return actor.parameters[2, @level]
end
#--------------------------------------------------------------------------
# ● 获取自身防御力
#--------------------------------------------------------------------------
def self_def
return actor.parameters[3, @level]
end
#--------------------------------------------------------------------------
# ● 获取自身精神力
#--------------------------------------------------------------------------
def self_spi
return actor.parameters[4, @level]
end
#--------------------------------------------------------------------------
# ● 获取自身敏捷性
#--------------------------------------------------------------------------
def self_agi
return actor.parameters[5, @level]
end
#--------------------------------------------------------------------------
# ● 获取命中率
#--------------------------------------------------------------------------
def hit
n = 95
for e in equips.compact do n += e.hit end
return n
end
#--------------------------------------------------------------------------
# ● 获取回避率
#--------------------------------------------------------------------------
def eva
n = 5
for e in equips.compact do n += e.eva end
return n
end
#--------------------------------------------------------------------------
# ● 获取会心一击概率
#--------------------------------------------------------------------------
def cri
n = 4
n += 4 if actor.critical_bonus
for e in equips.compact do n += e.cri end
return n
end
#--------------------------------------------------------------------------
# ● 获取更多经验值
#--------------------------------------------------------------------------
def exp_added
exp = 100
for equip in equips.compact
exp += equip.exp
end
return exp
end
#--------------------------------------------------------------------------
# ● 获取高级物品暴率
#--------------------------------------------------------------------------
def equip_chance
equip_chance = 0
for equip in equips.compact
equip_chance += equip.equip_chance
end
return equip_chance
end
#--------------------------------------------------------------------------
# ● 获得经验值 (考虑到附加经验值)
# exp : 经验值增加量
# show : 显示升级标志
#--------------------------------------------------------------------------
def gain_exp(exp, show)
change_exp(@exp + exp * exp_added, show)
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 初始化对象
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def initialize(actor_id)
super()
setup(actor_id)
@last_skill_id = 0
end
#--------------------------------------------------------------------------
# ● 设置
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
@character_name = actor.character_name
@character_index = actor.character_index
@face_name = actor.face_name
@face_index = actor.face_index
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
@level = actor.initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
for i in self.class.learnings
learn_skill(i.skill_id) if i.level <= @level
end
clear_extra_values
recover_all
## 生成新装备id
reset_equip_id
end
#--------------------------------------------------------------------------
# ● 装备重设
#--------------------------------------------------------------------------
def reset_equip_id
@weapon_id = Game_Equip.reini_id(@weapon_id, 0)
@armor1_id = Game_Equip.reini_id(@armor1_id, two_hands_legal? ? 0 : 1)
@armor2_id = Game_Equip.reini_id(@armor2_id, 1)
@armor3_id = Game_Equip.reini_id(@armor3_id, 1)
@armor4_id = Game_Equip.reini_id(@armor4_id, 1)
end
#--------------------------------------------------------------------------
# ● 判断是否可以装备
# item : 物品
# base : 是否读取母版数据
#--------------------------------------------------------------------------
def equippable?(item, base = true)
id = base ? item.base_id : item.id
if item.is_a?(RPG::Weapon)
return self.class.weapon_set.include?(id)
elsif item.is_a?(RPG::Armor)
return false if two_swords_style and item.kind == 0
return self.class.armor_set.include?(id)
end
return false
end
#--------------------------------------------------------------------------
# ● 更改装备 (指定对象)
# equip_type : 装备部位 (0..4)
# item : 武器 or 防具 (nil 为解除装备)
# test : 测试标志 (战斗测试、以及装备画面的临时装备)
#--------------------------------------------------------------------------
def change_equip(equip_type, item, test = false)
last_item = equips[equip_type]
unless test
return if $game_party.item_number(item) == 0 if item != nil
$game_party.gain_item(last_item, 1)
$game_party.lose_item(item, 1)
last_item.actor_id = nil unless last_item.nil?
end
item_id = item == nil ? 0 : item.id
case equip_type
when 0 # 武器
@weapon_id = item_id
unless two_hands_legal? # 违反双手拿取的情况下
change_equip(1, nil, test) # 解除反手的装备
end
when 1 # 盾
@armor1_id = item_id
unless two_hands_legal? # 违反双手拿取的情况下
change_equip(0, nil, test) # 解除反手的装备
end
when 2 # 头
@armor2_id = item_id
when 3 # 身体
@armor3_id = item_id
when 4 # 装饰品
@armor4_id = item_id
end
item.actor_id = self.id unless item.nil?
end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 判断持有的物品
# item : 物品
# include_equip : 包括装备品
#--------------------------------------------------------------------------
def has_item_by_base_id?(item, include_equip = false)
for i in items
return true if i.base_id == item.id
end
if include_equip
for actor in members
for e in actor.equips
return true if e.base_id == item.id
end
end
end
return false
end
#--------------------------------------------------------------------------
# ● 获得物品
# item : 物品
# n : 个数
#--------------------------------------------------------------------------
def gain_reini(item, n, include_equip = false, *gift)
if n < 0
lose_item(item, -n, include_equip = false)
else
case item
when RPG::Item
number = item_number(item)
@items[item.id] = [[number + n, 0].max, 99].min
when RPG::Weapon
for i in 0...n
w = Game_Equip.reini(item, *gift)
@weapons[w.id] = 1
end
when RPG::Armor
for i in 0...n
a = Game_Equip.reini(item, *gift)
@armors[a.id] = 1
end
end
end
end
#--------------------------------------------------------------------------
# ● 减少物品 (减少)
# item : 物品
# n : 个数
# include_equip : 包括装备品
#--------------------------------------------------------------------------
def lose_reini(item, n, include_equip = false)
number = item_number(item)
case item
when RPG::Item
@items[item.id] = [[number - n, 0].max, 99].min
when RPG::Weapon
@weapons[item.id] = [[number - n, 0].max, 99].min
when RPG::Armor
@armors[item.id] = [[number - n, 0].max, 99].min
end
n -= number
if include_equip and n > 0
for actor in members
while n > 0 and actor.equips.include?(item)
actor.discard_equip(item)
n -= 1
end
end
end
end
#--------------------------------------------------------------------------
# ● 获得物品
# item_id : 物品id
# type : 类型(0物品, 1武器, 2防具)
# n : 个数
#--------------------------------------------------------------------------
def gain_reini_byid(item_id, type, n, include_equip = false, *gift)
case type
when 0
item = $data_items[item_id]
when 1
item = $base_weapons[item_id]
when 2
item = $base_armors[item_id]
end
gain_reini(item, n, include_equip, *gift)
end
#--------------------------------------------------------------------------
# ● 极品爆率
#--------------------------------------------------------------------------
def equip_chance
chance = Game_Equip::Equip_Chance[0]
members.each {|actor| chance += actor.equip_chance}
return chance
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● 敌人角色名称后的文字表
#--------------------------------------------------------------------------
LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z']
#--------------------------------------------------------------------------
# ● 生成掉落物品队列
#--------------------------------------------------------------------------
def make_drop_items
drop_items = []
for enemy in dead_members
for di in [enemy.drop_item1, enemy.drop_item2]
next if di.kind == 0
next if rand(di.denominator) != 0
if di.kind == 1
drop_items.push($data_items[di.item_id])
elsif di.kind == 2
item = reini_chance($base_weapons[di.weapon_id], $game_party.equip_chance)
drop_items.push(item)
elsif di.kind == 3
item = reini_chance($base_armors[di.weapon_id], $game_party.equip_chance)
drop_items.push(item)
end
end
end
return drop_items
end
#--------------------------------------------------------------------------
# ● 处理极品爆率
#--------------------------------------------------------------------------
def reini_chance(item, chance)
@item = item
@chance = [chance/100.0, Game_Equip::Equip_Chance[1]/100.0].min
@gifts = []
loop do
if rand(0) < @chance and @gifts.size < Game_Equip::GiftMax
@gifts << Game_Gift.new
@chance /= 2
else
return Game_Equip.reini(@item, @gifts)
end
end
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 计算操作的值
# operation : 操作 (0:增加 1:减少)
# operand_type : 运算域类型 (0:常量 1:变量)
# operand : 运算域 (数值为变量 ID)
#--------------------------------------------------------------------------
def operate_value(operation, operand_type, operand)
if operand_type == 0
value = operand
else
value = $game_variables[operand]
end
if operation == 1
value = -value
end
return value
end
#--------------------------------------------------------------------------
# ● 条件分歧
#--------------------------------------------------------------------------
def command_111
result = false
case @params[0]
when 0 # 开关
result = ($game_switches[@params[1]] == (@params[2] == 0))
when 1 # 变量
value1 = $game_variables[@params[1]]
if @params[2] == 0
value2 = @params[3]
else
value2 = $game_variables[@params[3]]
end
case @params[4]
when 0 # 相等
result = (value1 == value2)
when 1 # 大于等于
result = (value1 >= value2)
when 2 # 小于等于
result = (value1 <= value2)
when 3 # 大于
result = (value1 > value2)
when 4 # 小于
result = (value1 < value2)
when 5 # 不等于
result = (value1 != value2)
end
when 2 # 自我开关
if @original_event_id > 0
key = [@map_id, @original_event_id, @params[1]]
if @params[2] == 0
result = ($game_self_switches[key] == true)
else
result = ($game_self_switches[key] != true)
end
end
when 3 # 计时器
if $game_system.timer_working
sec = $game_system.timer / Graphics.frame_rate
if @params[2] == 0
result = (sec >= @params[1])
else
result = (sec <= @params[1])
end
end
when 4 # 角色
actor = $game_actors[@params[1]]
if actor != nil
case @params[2]
when 0 # 是同伴
result = ($game_party.members.include?(actor))
when 1 # 姓名
result = (actor.name == @params[3])
when 2 # 特技
result = (actor.skill_learn?($data_skills[@params[3]]))
when 3 # 武器
## 判断是否符合母版id
actor.weapons.each do |weapon|
if weapon.base_id == @params[3]
result = true
break
end
end
when 4 # 防具
## 判断是否符合母版id
actor.armors.each do |armor|
if armor.base_id == @params[3]
result = true
break
end
end
when 5 # 状态
result = (actor.state?(@params[3]))
end
end
when 5 # 敌方角色
enemy = $game_troop.members[@params[1]]
if enemy != nil
case @params[2]
when 0 # 出现
result = (enemy.exist?)
when 1 # 状态
result = (enemy.state?(@params[3]))
end
end
when 6 # 角色
character = get_character(@params[1])
if character != nil
result = (character.direction == @params[2])
end
when 7 # 金钱
if @params[2] == 0
result = ($game_party.gold >= @params[1])
else
result = ($game_party.gold <= @params[1])
end
when 8 # 物品
result = $game_party.has_item?($data_items[@params[1]])
when 9 # 武器
result = $game_party.has_item_by_base_id?($base_weapons[@params[1]], @params[2])
when 10 # 防具
result = $game_party.has_item_by_base_id?($base_armors[@params[1]], @params[2])
when 11 # 按钮
result = Input.press?(@params[1])
when 12 # 脚本
result = eval(@params[1])
when 13 # 交通工具
result = ($game_player.vehicle_type == @params[1])
end
@branch[@indent] = result # 将判断结果放置在缓存中
if @branch[@indent] == true
@branch.delete(@indent)
return true
end
return command_skip
end
#--------------------------------------------------------------------------
# ● 计算装备操作的值
# operand_type : 运算域类型 (0:常量 1:变量)
# operand : 运算域 (数值为变量 ID)
#--------------------------------------------------------------------------
def opera_equip_value(operation, operand_type, operand)
if operand_type == 0
value = operand
else
value = $game_variables[operand]
end
return value
end
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def command_127
value = operate_value(@params[1], @params[2], @params[3])
if @params[1] == 0
$game_party.gain_reini($base_weapons[@params[0]], value.abs, @params[4])
else
$game_party.lose_reini($base_weapons[@params[0]], value.abs, @params[4])
end
return true
end
#--------------------------------------------------------------------------
# ● 增减防具
#--------------------------------------------------------------------------
def command_128
value = operate_value(@params[1], @params[2], @params[3])
if @params[1] == 0
$game_party.gain_reini($base_armors[@params[0]], value.abs, @params[4])
else
$game_party.lose_reini($base_armors[@params[0]], value.abs, @params[4])
end
return true
end
#--------------------------------------------------------------------------
# ● 更改装备
#--------------------------------------------------------------------------
def command_319
actor = $game_actors[@params[0]]
if actor != nil
actor.change_equip_by_id(@params[1], @params[2])
end
return true
end
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def get_weapon(id, n, *gift)
$game_party.gain_reini($base_weapons[id], n, false, *gift)
end
#--------------------------------------------------------------------------
# ● 增减防具
#--------------------------------------------------------------------------
def get_armor(id, n, *gift)
$game_party.gain_reini($base_armors[id], n, false, *gift)
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
def draw_item_name(item, x, y, enabled = true)
if item != nil
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = text_color(item.text_color.to_i)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 172, WLH, item.name)
end
end
end
#==============================================================================
# ■ Window_ShopBuy
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $base_items[goods_item[1]]
when 1
item = $base_weapons[goods_item[1]]
when 2
item = $base_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
end
#==============================================================================
# ■ Window_ShopStatus
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● 描绘角色现在装备的能力值变化
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_parameter_change(actor, x, y)
return if @item.is_a?(RPG::Item)
enabled = actor.equippable?(@item, false)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x, y, 200, WLH, actor.name)
if @item.is_a?(RPG::Weapon)
item1 = weaker_weapon(actor)
elsif actor.two_swords_style and @item.kind == 0
item1 = nil
else
item1 = actor.equips[1 + @item.kind]
end
if enabled
if @item.is_a?(RPG::Weapon)
atk1 = item1 == nil ? 0 : item1.atk
atk2 = @item == nil ? 0 : @item.atk
change = atk2 - atk1
else
def1 = item1 == nil ? 0 : item1.def
def2 = @item == nil ? 0 : @item.def
change = def2 - def1
end
self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
end
draw_item_name(item1, x, y + WLH, enabled)
end
end
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● 写入存档数据
# file : 写入文件用对象 (已经打开)
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push([actor.character_name, actor.character_index])
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($data_weapons, file)
Marshal.dump($data_armors, file)
end
#--------------------------------------------------------------------------
# ● 读取存档数据
# file : 读取文件用对象 (已经打开)
#--------------------------------------------------------------------------
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$data_weapons = Marshal.load(file)
$data_armors = Marshal.load(file)
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
end
#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 确定输入个数
#--------------------------------------------------------------------------
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 购买
$game_party.lose_gold(@number_window.number * @item.price)
$game_party.gain_reini(@item, @number_window.number)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
$game_party.gain_gold(@number_window.number * (@item.price / 2))
$game_party.lose_reini_item(@item, @number_window.number)
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
end
end
#==============================================================================
# ■ Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# ● 载入数据库
#--------------------------------------------------------------------------
def load_database
$data_actors = load_data("Data/Actors.rvdata")
$data_classes = load_data("Data/Classes.rvdata")
$data_skills = load_data("Data/Skills.rvdata")
$data_items = load_data("Data/Items.rvdata")
$base_weapons = load_data("Data/Weapons.rvdata")
$base_armors = load_data("Data/Armors.rvdata")
$data_enemies = load_data("Data/Enemies.rvdata")
$data_troops = load_data("Data/Troops.rvdata")
$data_states = load_data("Data/States.rvdata")
$data_animations = load_data("Data/Animations.rvdata")
$data_common_events = load_data("Data/CommonEvents.rvdata")
$data_system = load_data("Data/System.rvdata")
$data_areas = load_data("Data/Areas.rvdata")
$data_weapons = [nil]
$data_armors = [nil]
end
#--------------------------------------------------------------------------
# ● 载入战斗测试用的数据库
#--------------------------------------------------------------------------
def load_bt_database
$data_actors = load_data("Data/BT_Actors.rvdata")
$data_classes = load_data("Data/BT_Classes.rvdata")
$data_skills = load_data("Data/BT_Skills.rvdata")
$data_items = load_data("Data/BT_Items.rvdata")
$data_weapons = load_data("Data/BT_Weapons.rvdata")
$data_armors = load_data("Data/BT_Armors.rvdata")
$data_enemies = load_data("Data/BT_Enemies.rvdata")
$data_troops = load_data("Data/BT_Troops.rvdata")
$data_states = load_data("Data/BT_States.rvdata")
$data_animations = load_data("Data/BT_Animations.rvdata")
$data_common_events = load_data("Data/BT_CommonEvents.rvdata")
$data_system = load_data("Data/BT_System.rvdata")
$base_weapons = $data_weapons
$base_armors = $data_armors
end
end作者: 迦月 时间: 2009-7-27 11:43
怎么没人能帮我看看嘛?
我想是不是Z轴描述出了问题啊? 高人 看看拜托~~作者: doublehjb 时间: 2009-7-27 14:21
应该是脚本冲突....LZ把那么一大堆脚本搬出来肯定没人看,没人理你的...........................
劝你还是2选1吧........................作者: 迦月 时间: 2009-7-27 16:21
冲突的位置大体知道在什么位置,现在就是不知道怎么改··我把它改成了纵版CP了···
我汗··作者: 小闵 时间: 2009-7-30 00:36
哇~好大堆的脚本...
LZ你可以点【插入代码】的...
伱这么厉害的脚本估计没多少个人会帮伱看....作者: zh99998 时间: 2009-8-2 08:21