Project1
标题:
即时消息脚本怎么改才能多个地图用
[打印本页]
作者:
酱爆
时间:
2010-12-14 18:58
标题:
即时消息脚本怎么改才能多个地图用
https://rpg.blue/forum.php?mod=attachment&aid=Mzk1NTd8MjQ5MDlkMzBmZjBkZDA2MTZlYTdkOTlhMDFhZTcwMjl8MTczMjQyMDU2Nw%3D%3D&request=yes&_f=.rar
Project1.rar
(241.5 KB, 下载次数: 58)
2010-12-14 18:57 上传
点击文件名下载附件
即时消息脚本怎么改才能在多个地图使用
#------------------制作by bluefool,转载请保留------------------
module Blue
#这个是控制显示最近的多少条信息的,当超出一屏能显示的值的话可通过先按一下shift
#然后用上下翻看内容。再按一次shift则解除激活
Blue_max = 12
#这个填写进如游戏时生成的系统语言,
INTRO = "官方网站:http://44rpg.uueasy.com"
#战斗画面时即时消息窗口的x坐标
BATAM_X = 0
#战斗画面时即时消息窗口的y坐标
BATAM_Y = 90
#用于清空hash表,可以不管它,但不要让Blue_max大于它,当然,它的值也可以改变
NAM_MAX = 50
#主要传递信息参数为函数$am,参见脚本内容
end
#-------------------------------------------
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open(filename, "rb")
read_save_data(file)
file.close
# 还原 BGM、BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# 刷新地图 (执行并行事件)
$a = {}
$game_map.update
# 切换到地图画面
$scene = Scene_Map.new
end
end
class Game_Player < Game_Character
def update
# 本地变量记录移动信息
last_moving = moving?
# 移动中、事件执行中、强制移动路线中、
# 信息窗口一个也不显示的时候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing or $ccc == 1
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地变量记忆坐标
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移动、画面上的位置在中央下方的情况下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 画面向下卷动
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移动、画面上的位置在中央左方的情况下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 画面向左卷动
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移动、画面上的位置在中央右方的情况下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 画面向右卷动
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移动、画面上的位置在中央上方的情况下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 画面向上卷动
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移动中的情况下
unless moving?
# 上次主角移动中的情况
if last_moving
# 与同位置的事件接触就判定为事件启动
result = check_event_trigger_here([1,2])
# 没有可以启动的事件的情况下
if result == false
# 调试模式为 ON 并且按下 CTRL 键的情况下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敌计数下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 判定为同位置以及正面的事件启动
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
# 处理标题画面的类。
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● 命令 : 新游戏
#--------------------------------------------------------------------------
def command_new_game
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 停止 BGM
Audio.bgm_stop
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# 设置初期同伴位置
$game_party.setup_starting_members
# 设置初期位置的地图
$game_map.setup($data_system.start_map_id)
# 主角向初期位置移动
$game_player.moveto($data_system.start_x, $data_system.start_y)
# 刷新主角
$game_player.refresh
# 执行地图设置的 BGM 与 BGS 的自动切换
$game_map.autoplay
# 刷新地图 (执行并行事件)
$game_map.update
$a = {}
$am = Blue::INTRO
$ccc = 0
# 切换地图画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 命令 : 继续
#--------------------------------------------------------------------------
def command_continue
# 继续无效的情况下
unless @continue_enabled
# 演奏无效 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到读档画面
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# ● 命令 : 退出
#--------------------------------------------------------------------------
def command_shutdown
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# BGM、BGS、ME 的淡入淡出
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 退出
$scene = nil
end
#--------------------------------------------------------------------------
# ● 战斗测试
#--------------------------------------------------------------------------
def battle_test
# 载入数据库 (战斗测试用)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$a = {0=>"进入战斗测试."}
# 设置战斗测试用同伴
$game_party.setup_battle_test_members
# 设置队伍 ID、可以逃走标志、战斗背景
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# 演奏战斗开始 BGM
$game_system.se_play($data_system.battle_start_se)
# 演奏战斗 BGM
$game_system.bgm_play($game_system.battle_bgm)
# 切换到战斗画面
$scene = Scene_Battle.new
end
end
#-------------------------------------------------------
class Scene_Map
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
@down_window = Window_Down.new
####################################
@v = Viewport.new(0,460,320,20)
@v.color.set(0,0,0,120)
@tf = Type_Field.new(@v,"",16)
########################################懒虫
Graphics.transition
# 主循环
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@message_window.dispose
@down_window.dispose
############
@v.dispose
@tf.dispose
###############
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
@am_size = $a.size
end
#---------------------
def bluefool_sort
if $am != nil
if $a.size > Blue::NAM_MAX
a_temp = {}
j = 0
for i in ($a.size - Blue::Blue_max)...$a.size
a_temp[j] = $a[i]
j += 1
end
$a = a_temp
end
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 循环
loop do
# 按照地图、实例、主角的顺序刷新
# (本更新顺序不会在的满足事件的执行条件下成为给予角色瞬间移动
# 的机会的重要因素)
$game_map.update
$game_system.map_interpreter.update
$game_player.update
# 系统 (计时器)、画面刷新
$game_system.update
$game_screen.update
# 如果主角在场所移动中就中断循环
unless $game_temp.player_transferring
break
end
# 执行场所移动
transfer_player
# 处理过渡中的情况下、中断循环
if $game_temp.transition_processing
break
end
end
# 刷新活动块
@spriteset.update
# 刷新信息窗口
###########################懒虫到此一游###########################
# 输入法测试
@tf.update
if RInput.trigger?(RInput::ENTER) and Input.press?(Input::CTRL)
if (text = @tf.get_text) != ""
$am = @tf.get_text
$scene = Scene_Map.new
end
end
##################################官方http://rpg.6te.net##########
@message_window.update
# 游戏结束的情况下
if $game_temp.gameover
# 切换的游戏结束画面
$scene = Scene_Gameover.new
return
end
# 返回标题画面的情况下
if $game_temp.to_title
# 切换到标题画面
$scene = Scene_Title.new
return
end
# 处理过渡中的情况下
if $game_temp.transition_processing
# 清除过渡处理中标志
$game_temp.transition_processing = false
# 执行过渡
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# 显示信息窗口中的情况下
if $game_temp.message_window_showing
return
end
# 遇敌计数为 0 且、且遇敌列表不为空的情况下
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# 不是在事件执行中或者禁止遇敌中
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# 确定队伍
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# 队伍有效的话
if $data_troops[troop_id] != nil
# 设置调用战斗标志
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
#---------------------------------------------
bluefool_sort
if @am_size != $a.size
@down_window.refresh
if $a != nil and $a.size < Blue::Blue_max + 1
@down_window.index = $a.size/2 - 1
elsif $a != nil and $a.size > Blue::Blue_max
@down_window.index = Blue::Blue_max/2 - 1
end
@am_size = $a.size
end
if Input.trigger?(Input::A)
if @down_window.active == false
@down_window.active = true
$ccc = 1
else
@down_window.active = false
$ccc = 0
end
end
if Input.trigger?(Input::DOWN)#输入DOWN键的情况
if @down_window.active == true and @down_window.index < (@down_window.item_max-1)/2
@down_window.index += 1
end
end
if Input.trigger?(Input::UP)#输入UP键的情况
if @down_window.active == true and @down_window.index > 0
@down_window.index -= 1
end
end
#----------------------------------------------
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 不是在事件执行中或菜单禁止中
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# 设置菜单调用标志以及 SE 演奏
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# 调试模式为 ON 并且按下 F9 键的情况下
if $DEBUG and Input.press?(Input::F9)
# 设置调用调试标志
$game_temp.debug_calling = true
end
# 不在主角移动中的情况下
unless $game_player.moving?
# 执行各种画面的调用
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
end
class Game_Battler
def bluefool_sort
if $am != nil
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
#--------------------------------------------------------------------------
# ● 应用连续伤害效果
#--------------------------------------------------------------------------
def slip_damage_effect
# 设置伤害
self.damage = self.maxhp / 10
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# HP 的伤害减法运算
self.hp -= self.damage
if self.damage > 0
$am = "异常状态使#{self.name}受到了#{self.damage}点伤害."
elsif self.damage < 0
$am = "异常状态使#{self.name}恢复了#{self.damage.abs}点#{$data_system.words.hp}"
end
bluefool_sort
# 过程结束
return true
end
#--------------------------------------------------------------------------
# ● 应用通常攻击效果
# attacker : 攻击者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
# 清除会心一击标志
self.critical = false
# 第一命中判定
hit_result = (rand(100) < attacker.hit)
# 命中的情况下
if hit_result == true
# 计算基本伤害
atk = [attacker.atk - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
# 属性修正
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 会心一击修正
if rand(100) < 4 * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# 命中的情况下
if hit_result == true
# 状态冲击解除
remove_states_shock
# HP 的伤害计算
self.hp -= self.damage
$am = "#{attacker.name}对#{self.name}造成了#{self.damage}伤害."
bluefool_sort
# 状态变化
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
$am = "#{attacker.name}击空了."
bluefool_sort
# 清除会心一击标志
self.critical = false
end
# 过程结束
return true
end
#--------------------------------------------------------------------------
# ● 应用特技效果
# user : 特技的使用者 (battler)
# skill : 特技
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# 清除会心一击标志
self.critical = false
# 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
# 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# 过程结束
return false
end
# 清除有效标志
effective = false
# 公共事件 ID 是有效的情况下,设置为有效标志
effective |= skill.common_event_id > 0
# 第一命中判定
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
# 命中的情况下
if hit_result == true
# 计算威力
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# 计算倍率
rate = 20
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
# 计算基本伤害
self.damage = power * rate / 20
# 属性修正
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
end
# 命中的情况下
if hit_result == true
# 威力 0 以外的物理攻击的情况下
if skill.power != 0 and skill.atk_f > 0
# 状态冲击解除
remove_states_shock
# 设置有效标志
effective = true
end
# HP 的伤害减法运算
last_hp = self.hp
self.hp -= self.damage
if self.damage > 0
$am = "#{user.name}对#{self.name}造成了#{self.damage}伤害."
elsif self.damage < 0
if user == self
$am = "#{user.name}恢复了自己#{self.damage.abs}点#{$data_system.words.hp}."
else
$am = "#{user.name}恢复了#{self.name}#{self.damage.abs}点#{$data_system.words.hp}."
end
end
bluefool_sort
effective |= self.hp != last_hp
# 状态变化
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# 威力为 0 的场合
if skill.power == 0
# 伤害设置为空的字串
self.damage = ""
# 状态没有变化的情况下
unless @state_changed
# 伤害设置为 "Miss"
self.damage = "Miss"
$am = "#{user.name}没有击中."
bluefool_sort
end
end
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
$am = "#{user.name}没有击中."
bluefool_sort
end
# 不在战斗中的情况下
unless $game_temp.in_battle
# 伤害设置为 nil
self.damage = nil
end
# 过程结束
return effective
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 1 : 准备行动)
#--------------------------------------------------------------------------
def update_phase4_step1
# 隐藏帮助窗口
@help_window.visible = false
# 判定胜败
if judge
# 胜利或者失败的情况下 : 过程结束
return
end
# 强制行动的战斗者不存在的情况下
if $game_temp.forcing_battler == nil
# 设置战斗事件
setup_battle_event
# 执行战斗事件中的情况下
if $game_system.battle_interpreter.running?
return
end
end
# 强制行动的战斗者存在的情况下
if $game_temp.forcing_battler != nil
# 在头部添加后移动
@action_battlers.delete($game_temp.forcing_battler)
@action_battlers.unshift($game_temp.forcing_battler)
end
# 未行动的战斗者不存在的情况下 (全员已经行动)
if @action_battlers.size == 0
# 开始同伴命令回合
start_phase2
return
end
# 初始化动画 ID 和公共事件 ID
@animation1_id = 0
@animation2_id = 0
@common_event_id = 0
# 未行动的战斗者移动到序列的头部
@active_battler = @action_battlers.shift
# 如果已经在战斗之外的情况下
if @active_battler.index == nil
return
end
# 连续伤害
if @active_battler.hp > 0 and @active_battler.slip_damage?
@active_battler.slip_damage_effect
@active_battler.damage_pop = true
@down_window.refresh
end
# 自然解除状态
@active_battler.remove_states_auto
# 刷新状态窗口
@status_window.refresh
# 移至步骤 2
@phase4_step = 2
end
#--------------------------------------------------------------------------
# ● 开始结束战斗回合
#--------------------------------------------------------------------------
def start_phase5
# 转移到回合 5
@phase = 5
# 演奏战斗结束 ME
$game_system.me_play($game_system.battle_end_me)
# 还原为战斗开始前的 BGM
$game_system.bgm_play($game_temp.map_bgm)
# 初始化 EXP、金钱、宝物
exp = 0
gold = 0
treasures = []
# 循环
for enemy in $game_troop.enemies
# 敌人不是隐藏状态的情况下
unless enemy.hidden
# 获得 EXP、增加金钱
exp += enemy.exp
gold += enemy.gold
# 出现宝物判定
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
# 限制宝物数为 6 个
treasures = treasures[0..5]
# 获得 EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# 获得金钱
$game_party.gain_gold(gold)
$am = "获得#{exp}经验,#{gold}#{$data_system.words.gold}"
bluefool_sort
@down_window.refresh
# 获得宝物
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
$am = "获得#{$data_items[item.id].name}"
bluefool_sort
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
$am = "获得#{$data_weapons[item.id].name}"
bluefool_sort
when RPG::Armor
$game_party.gain_armor(item.id, 1)
$am = "获得#{$data_armors[item.id].name}"
bluefool_sort
end
@down_window.refresh
end
# 生成战斗结果窗口
@result_window = Window_BattleResult.new(exp, gold, treasures)
# 设置等待计数
@phase5_wait_count = 100
end
#--------------------------------------------------------------------------
# ● 生成基本行动结果
#--------------------------------------------------------------------------
def make_basic_action_result
# 攻击的情况下
if @active_battler.current_action.basic == 0
# 设置攻击 ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# 行动方的战斗者是敌人的情况下
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
end
# 行动方的战斗者是角色的情况下
if @active_battler.is_a?(Game_Actor)
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
# 设置对像方的战斗者序列
@target_battlers = [target]
for target in @target_battlers
$am = "#{@active_battler.name}对#{target.name}发起了进攻!"
bluefool_sort
target.attack_effect(@active_battler)
end
return
end
# 防御的情况下
if @active_battler.current_action.basic == 1
@help_window.set_text($data_system.words.guard, 1)
$am = "#{@active_battler.name}选择了防御."
bluefool_sort
return
end
# 逃跑的情况下
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
# 帮助窗口显示"逃跑"
@help_window.set_text("逃跑", 1)
# 逃跑
@active_battler.escape
return
end
# 什么也不做的情况下
if @active_battler.current_action.basic == 3
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
#--------------------------------------------------------------------------
# ● 生成特技行动结果
#--------------------------------------------------------------------------
def make_skill_action_result
# 获取特技
@skill = $data_skills[@active_battler.current_action.skill_id]
# 如果不是强制行动
unless @active_battler.current_action.forcing
# 因为 SP 耗尽而无法使用的情况下
unless @active_battler.skill_can_use?(@skill.id)
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
# 消耗 SP
@active_battler.sp -= @skill.sp_cost
# 刷新状态窗口
@status_window.refresh
# 在帮助窗口显示特技名
@help_window.set_text(@skill.name, 1)
# 设置动画 ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# 设置公共事件 ID
@common_event_id = @skill.common_event_id
# 设置对像侧战斗者
set_target_battlers(@skill.scope)
# 应用特技效果
for target in @target_battlers
case @skill.scope
when 1
$am = "#{@active_battler.name}使用#{@skill.name}攻击#{target.name}!"
when 2
$am = "#{@active_battler.name}使用#{@skill.name}攻击#{target.name}!"
when 7
$am = "#{@active_battler.name}对自己使用#{@skill.name}."
else
if target == @active_battler
$am = "#{@active_battler.name}对自己使用#{@skill.name}."
else
$am = "#{@active_battler.name}对#{target.name}使用#{@skill.name}."
end
end
bluefool_sort
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# ● 生成物品行动结果
#--------------------------------------------------------------------------
def make_item_action_result
# 获取物品
@item = $data_items[@active_battler.current_action.item_id]
# 因为物品耗尽而无法使用的情况下
unless $game_party.item_can_use?(@item.id)
# 移至步骤 1
@phase4_step = 1
return
end
# 消耗品的情况下
if @item.consumable
# 使用的物品减 1
$game_party.lose_item(@item.id, 1)
end
# 在帮助窗口显示物品名
@help_window.set_text(@item.name, 1)
# 设置动画 ID
@animation1_id = @item.animation1_id
@animation2_id = @item.animation2_id
# 设置公共事件 ID
@common_event_id = @item.common_event_id
# 确定对像
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
# 设置对像侧战斗者
set_target_battlers(@item.scope)
# 应用物品效果
for target in @target_battlers
target.item_effect(@item)
if target == @active_battler
$am = "#{@active_battler.name}对自己使用了#{@item.name}"
else
$am = "#{@active_battler.name}对#{target.name}使用了#{@item.name}"
end
bluefool_sort
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 4 : 对像方动画)
#--------------------------------------------------------------------------
def update_phase4_step4
# 对像方动画
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
end
@down_window.refresh
@wait_count = 8
# 移至步骤 5
@phase4_step = 5
end
def bluefool_sort
if $am != nil
if $a.size > Blue::NAM_MAX
a_temp = {}
j = 0
for i in ($a.size - Blue::Blue_max)...$a.size
a_temp[j] = $a[i]
j += 1
end
$a = a_temp
end
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
def main
$am = "队伍进入战斗!"
bluefool_sort
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
$game_system.battle_interpreter.setup(nil, 0)
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
#生成角色命令窗口
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
# 生成其它窗口
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@status_window = Window_BattleStatus.new
@message_window = Window_Message.new
@down_window = Window_Down.new
@down_window.y = Blue::BATAM_Y
@down_window.z = @actor_command_window.z - 10
# 生成活动块
@spriteset = Spriteset_Battle.new
# 初始化等待计数
@wait_count = 0
# 执行过渡
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# 开始自由战斗回合
start_phase1
# 主循环
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
# 刷新地图
$game_map.refresh
# 准备过渡
Graphics.freeze
# 释放窗口
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
@down_window.dispose
$am = "战斗结束"
bluefool_sort
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# 释放活动块
@spriteset.dispose
# 标题画面切换中的情况
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
# 战斗测试或者游戏结束以外的画面切换中的情况
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
end
#---------------------------------------------------------
class Interpreter
def bluefool_sort
if $am != nil
if $a.size > Blue::NAM_MAX
a_temp = {}
j = 0
for i in ($a.size - Blue::Blue_max)...$a.size
a_temp[j] = $a[i]
j += 1
end
$a = a_temp
end
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
def command_101
if $game_temp.message_text != nil
return false
end
# 设置信息结束后待机和返回调用标志
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
# message_text 设置为 1 行
$game_temp.message_text = @list[@index].parameters[0] + "\n"
if (@list[@index].parameters[0]).split(/\\/)[1] != nil
$am = @list[@index].parameters[0].split(/\\/)[0]
else
$am = @list[@index].parameters[0]
end
bluefool_sort
line_count = 1
# 循环
loop do
# 下一个事件指令为文章两行以上的情况
if @list[@index+1].code == 401
# message_text 添加到第 2 行以下
$game_temp.message_text += @list[@index+1].parameters[0] + "\n"
$am = @list[@index+1].parameters[0]
bluefool_sort
line_count += 1
# 事件指令不在文章两行以下的情况
else
# 下一个事件指令为显示选择项的情况下
if @list[@index+1].code == 102
# 如果选择项能收纳在画面里
if @list[@index+1].parameters[0].size <= 4 - line_count
# 推进索引
@index += 1
# 设置选择项
$game_temp.choice_start = line_count
setup_choices(@list[@index].parameters)
end
# 下一个事件指令为处理输入数值的情况下
elsif @list[@index+1].code == 103
# 如果数值输入窗口能收纳在画面里
if line_count < 4
# 推进索引
@index += 1
# 设置输入数值
$game_temp.num_input_start = line_count
$game_temp.num_input_variable_id = @list[@index].parameters[0]
$game_temp.num_input_digits_max = @list[@index].parameters[1]
end
end
# 继续
return true
end
# 推进索引
@index += 1
end
end
def command_125
value = operate_value(@parameters[0], @parameters[1], @parameters[2])
$game_party.gain_gold(value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value}#{$data_system.words.gold}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}#{$data_system.words.gold}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_126
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 增减物品
$game_party.gain_item(@parameters[0], value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value.abs.to_s}个#{$data_items[@parameters[0]].name}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}个#{$data_items[@parameters[0]].name}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_127
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 增减武器
$game_party.gain_weapon(@parameters[0], value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value.abs.to_s}个#{$data_weapons[@parameters[0]].name}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}个#{$data_weapons[@parameters[0]].name}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_128
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 增减防具
$game_party.gain_armor(@parameters[0], value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value.abs.to_s}个#{$data_armors[@parameters[0]].name}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}个#{$data_armors[@parameters[0]].name}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_129
# 获取角色
actor = $game_actors[@parameters[0]]
# 角色有效的情况下
if actor != nil
# 操作分支
if @parameters[1] == 0
if @parameters[2] == 1
$game_actors[@parameters[0]].setup(@parameters[0])
end
$game_party.add_actor(@parameters[0])
Audio.me_play("Audio/ME/"+"002-Victory02",100,100)
$am = "#{$game_actors[@parameters[0]].name}加入队伍!"
bluefool_sort
else
$game_party.remove_actor(@parameters[0])
Audio.me_play("Audio/ME/"+"015-Mystery01",100,100)
$am = "#{$game_actors[@parameters[0]].name}离开队伍!"
bluefool_sort
end
end
# 继续
return true
end
#-------------------------
end
#==============================================================================
# ■ Window_Down
#------------------------------------------------------------------------------
# 信息窗口。
#==============================================================================
class Window_Down < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 240, 330, 240)
@column_max = 1
self.opacity = 0
if $a != nil and $a.size < 21
self.index = $a.size/2
elsif $a != nil and $a.size > 20
self.index = 9
end
refresh
self.active = false
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
if $a != nil and $a.size < Blue::Blue_max + 1
@item_max = $a.size
elsif $a != nil and $a.size > Blue::Blue_max
@item_max = Blue::Blue_max
end
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 16)
for i in 0...@item_max
draw_item(i)
end
end
end
def item_max
return @item_max
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
if $a.size < Blue::Blue_max + 1
item = $a[index]
else
item = $a[index + $a.size - Blue::Blue_max]
end
x = 0
y = index * 16
self.contents.font.size = 14
self.contents.font.color = Color.new(-170,-170,-170,255)
self.contents.draw_text(x + 6, y + 1, self.contents.text_size(item).width, 16, item, 0)
self.contents.font.color = normal_color
self.contents.draw_text(x + 5, y, self.contents.text_size(item).width, 16, item, 0)
end
#--------------------------------------
# ● 刷新光标
#--------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
cursor_width = 0
# 计算光标坐标
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 32 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, 16)
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1