设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3817|回复: 6
打印 上一主题 下一主题

[已经解决] 求大神帮我改下脚本。

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
86 小时
注册时间
2012-10-27
帖子
16
跳转到指定楼层
1
发表于 2012-12-22 12:55:06 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
5星屑
还是行动条脚本的问题。前几天在这区求到了一个行动条脚本。
效果为在画面上端显示一个横条,敌我双方的“小图标”在上面从左向右走。
但是这个脚本里的图标只有2种。开战几回合之后,我方图标之间和敌方图标之间就彻底混在一起了。
无法精确的安排战术。
希望大神帮我修改一下,能给敌方某些人物设定“特殊的战斗图标”能给我方全员设定“战斗图标”。
拜托了!真的很需要这个效果。[code]#==============================================================================
# ■ CP制战斗系统 v1.00
#------------------------------------------------------------------------------
#    适用于:RPG Maker VX Ace
#    说明:把脚本放在Main的前面。
#    所需素材:Graphics\Pictures\SL我方.png,SL敌方.png。
#==============================================================================

#encoding:utf-8
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  战斗画面
#==============================================================================

class Scene_Battle < Scene_Base
  attr_accessor :cp_quota
  attr_accessor :rtab_wait
  attr_accessor :active_members
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    super
    @cp_quota = 0
    create_spriteset
    create_all_windows
    BattleManager.method_wait_for_message = method(:wait_for_message)
  end
  #--------------------------------------------------------------------------
  # ● 战斗开始
  #--------------------------------------------------------------------------
  def battle_start
    @rtab_wait = true
    @active_members = []
    BattleManager.battle_start
    set_cp_quota
    process_event
  end
  #--------------------------------------------------------------------------
  # ● 获取敌我双方人物的平均行动速度并决定CP槽的Quota值
  #--------------------------------------------------------------------------
  def set_cp_quota
    sss = 0.0
    for iii in $game_party.members
      sss += iii.param(6)
    end
    sss /= $game_party.members.size
    @cp_quota = sss * 45
    @spriteset.cp_quota = @cp_quota
    for iii in $game_party.members + $game_troop.members
      iii.cp_quota = @cp_quota
    end
  end
  #--------------------------------------------------------------------------
  # ● 进行下一个指令输入
  #--------------------------------------------------------------------------
  def next_command
    if BattleManager.next_command
      start_actor_command_selection
    else
      turn_start(@active_members)
    end
  end
  #--------------------------------------------------------------------------
  # ● 返回上一个指令输入
  #--------------------------------------------------------------------------
  def prior_command
    if BattleManager.prior_command
      start_actor_command_selection
    else
      start_party_command_selection
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if BattleManager.in_turn?
      process_event
      process_action
    else
      if @rtab_wait
        for iii in $game_party.members + $game_troop.members
          iii.in_turn = false
          iii.rtab_cp += iii.param(6)
          if iii.rtab_cp >= iii.cp_quota
            @active_members.push(iii)
            iii.in_turn = true
          end
        end
        if @active_members.size > 0
          @rtab_wait = false
          start_party_command_selection
        end
      end
    end
    BattleManager.judge_win_loss
  end
  #--------------------------------------------------------------------------
  # ● 回合开始
  #--------------------------------------------------------------------------
  def turn_start(members)
    @party_command_window.close
    @actor_command_window.close
    @status_window.unselect
    @subject = nil
    BattleManager.turn_start(members)
    @log_window.wait
    @log_window.clear
  end
  #--------------------------------------------------------------------------
  # ● 回合结束
  #--------------------------------------------------------------------------
  def turn_end
    @active_members.each do |battler|
      battler.on_turn_end
      refresh_status
      @log_window.display_auto_affected_status(battler)
      @log_window.wait_and_clear
    end
    BattleManager.turn_end
    process_event
    @rtab_wait = true
    @active_members = []
  end
  #--------------------------------------------------------------------------
  # ● 处理战斗行动
  #--------------------------------------------------------------------------
  def process_action
    return if scene_changing?
    if !@subject || [email protected]_action
      @subject = BattleManager.next_subject
    end
    return turn_end unless @subject
    if @subject.current_action
      @subject.current_action.prepare
      if @subject.current_action.valid?
        @status_window.open
        execute_action
      end
      @subject.remove_current_action
    end
    process_action_end unless @subject.current_action
  end
  #--------------------------------------------------------------------------
  # ● 开始队伍指令的选择
  #--------------------------------------------------------------------------
  def start_party_command_selection
    unless scene_changing?
      refresh_status
      @status_window.unselect
      @status_window.open
      if BattleManager.input_start
        BattleManager.clear_actor
        BattleManager.next_command
        @status_window.select(BattleManager.actor.index)
        @actor_command_window.setup(BattleManager.actor)
      else
        @party_command_window.deactivate
        @actor_command_window.close
        turn_start(@active_members)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成角色指令窗口
  #--------------------------------------------------------------------------
  def create_actor_command_window
    @actor_command_window = Window_ActorCommand.new
    @actor_command_window.viewport = @info_viewport
    @actor_command_window.set_handler(:attack, method(:command_attack))
    @actor_command_window.set_handler(:skill,  method(:command_skill))
    @actor_command_window.set_handler(:guard,  method(:command_guard))
    @actor_command_window.set_handler(:item,   method(:command_item))
    @actor_command_window.set_handler(:cancel, method(:prior_command))
    @actor_command_window.set_handler(:escape, method(:command_escape))
    @actor_command_window.x = Graphics.width
  end
  #--------------------------------------------------------------------------
  # ● 指令“撤退”
  #--------------------------------------------------------------------------
  def command_escape
    unless BattleManager.process_escape
      turn_start(@active_members)
      for iii in @active_members
        iii.rtab_cp = 0
      end
    end
  end
end

#encoding:utf-8
#==============================================================================
# ■ Window_ActorCommand
#------------------------------------------------------------------------------
#  战斗画面中,选择角色行动的窗口。
#==============================================================================

class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    return unless @actor
    add_attack_command
    add_skill_commands
    add_guard_command
    add_item_command
    add_escape_command
  end
  #--------------------------------------------------------------------------
  # ● 添加撤退指令
  #--------------------------------------------------------------------------
  def add_escape_command
    add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  end
end

#encoding:utf-8
#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  战斗过程的管理器。
#==============================================================================

module BattleManager
  #--------------------------------------------------------------------------
  # ● 战斗开始
  #--------------------------------------------------------------------------
  def self.battle_start
    $game_system.battle_count += 1
    $game_party.on_battle_start
    $game_troop.on_battle_start
    $game_troop.enemy_names.each do |name|
      $game_message.add(sprintf(Vocab::Emerge, name))
    end
    if @preemptive
      $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
    elsif @surprise
      $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
    end
    wait_for_message
  end
  #--------------------------------------------------------------------------
  # ● 遇敌时的处理
  #--------------------------------------------------------------------------
  def self.on_encounter
    @preemptive = false
    @surprise = false
  end
  #--------------------------------------------------------------------------
  # ● 回合开始
  #--------------------------------------------------------------------------
  def self.turn_start(members)
    @phase = :turn
    clear_actor
    $game_troop.increase_turn(members)
    make_action_orders(members)
  end
  #--------------------------------------------------------------------------
  # ● 生成行动顺序
  #--------------------------------------------------------------------------
  def self.make_action_orders(members)
    @action_battlers = []
    for iii in $game_party.members
      if members.include?(iii)
        @action_battlers.push(iii) unless @surprise
      end
    end
    for iii in $game_troop.members
      if members.include?(iii)
        @action_battlers.push(iii) unless @preemptive
      end
    end
    @action_battlers.each {|battler| battler.make_speed }
    @action_battlers.sort! {|a,b| b.speed - a.speed }
  end
end

#encoding:utf-8
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  处理战斗者的类。Game_Actor 和 Game_Enemy 类的父类。
#==============================================================================

class Game_Battler < Game_BattlerBase
  attr_accessor :turn_count
  attr_accessor :rtab_cp
  attr_accessor :cp_quota
  attr_accessor :in_turn
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  alias neoinitialize initialize
  def initialize
    @turn_count = 0
    @rtab_cp = 0
    @cp_quota = 100
    @in_turn = false
    neoinitialize
  end
  #--------------------------------------------------------------------------
  # ● 战斗开始处理
  #--------------------------------------------------------------------------
  def on_battle_start
    @turn_count = 0
    @rtab_cp = 0
    @cp_quota = 100
    @in_turn = false
    init_tp unless preserve_tp?
  end
  #--------------------------------------------------------------------------
  # ● 处理伤害
  #    调用前需要设置好
  #    @result.hp_damage   @result.mp_damage
  #    @result.hp_drain    @result.mp_drain
  #--------------------------------------------------------------------------
  def execute_damage(user)
    on_damage(@result.hp_damage) if @result.hp_damage > 0
    self.hp -= @result.hp_damage
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain
    # 受伤后计算CP退后量
    cpback = @result.hp_damage + @result.mp_damage
    cpback = (cpback < 0 ? 0 : cpback)
    pent = 100.0 * cpback / self.mhp
    cppentback = ((5 + pent / 10) * self.cp_quota / 100).to_i
    @rtab_cp -= cppentback
    @rtab_cp = (@rtab_cp < 0 ? 0 : @rtab_cp)
  end
  #--------------------------------------------------------------------------
  # ● 判定是否可以输入指令
  #--------------------------------------------------------------------------
  def inputable?
    normal? && !auto_battle? && @in_turn
  end
  #--------------------------------------------------------------------------
  # ● 回合结束处理
  #--------------------------------------------------------------------------
  def on_turn_end
    @result.clear
    regenerate_all
    update_state_turns
    update_buff_turns
    remove_states_auto(2)
    # 该角色的回合计数加1并清空CP
    @turn_count += 1
    @rtab_cp = 0
  end
end

#encoding:utf-8
#==============================================================================
# ■ Game_Troop
#------------------------------------------------------------------------------
#  管理敌群和战斗相关资料的类,也可执行如战斗事件管理之类的功能。
#   本类的实例请参考 $game_troop 。
#==============================================================================

class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ● 增加回合
  #--------------------------------------------------------------------------
  def increase_turn(members)
    troop.pages.each {|page| @event_flags

最佳答案

查看完整内容

修改脚本中def create_rtabcp_gauge #-------------------------------------------------------------------------- # ● 生成战斗CP条 #-------------------------------------------------------------------------- def create_rtabcp_gauge @cpgauge_back = Sprite.new(@viewport3) @cpgauge_back.bitmap = Bitmap.new(200, 8) @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 25 ...

Lv2.观梦者

梦石
0
星屑
465
在线时间
915 小时
注册时间
2011-5-11
帖子
438
2
发表于 2012-12-22 12:55:07 | 只看该作者
游系风 发表于 2012-12-22 14:25
不用战斗中换人,战前就换好了。
我想弄一个,除了主角外,其他同伴可以随便搭配的游戏(不同的角色,不 ...

修改脚本中def create_rtabcp_gauge
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 生成战斗CP条
  3.   #--------------------------------------------------------------------------
  4.   def create_rtabcp_gauge
  5.     @cpgauge_back = Sprite.new(@viewport3)
  6.     @cpgauge_back.bitmap = Bitmap.new(200, 8)
  7.     @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 255, 0), Color.new(255, 0, 0))
  8.     @cpgauge_back.x = 16
  9.     @cpgauge_back.y = 16
  10.     # 各个角色生成其图标
  11.    @icons = {}
  12.     for iii in $game_party.members
  13.       index=iii.id
  14.       @icons[iii] = Sprite.new(@viewport3)
  15.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/Actor/"+index.to_s+".png")
  16.       @icons[iii].ox = 12
  17.       @icons[iii].oy = 12
  18.       @icons[iii].x = 16
  19.       @icons[iii].y = 20
  20.       index+=1
  21.     end
  22.     for iii in $game_troop.members
  23.       index=iii.enemy_id
  24.       @icons[iii] = Sprite.new(@viewport3)
  25.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/Troop/"+index.to_s+".png")
  26.       @icons[iii].ox = 12
  27.       @icons[iii].oy = 12
  28.       @icons[iii].x = 16
  29.       @icons[iii].y = 20
  30.       index+=1
  31.     end
  32.   end

角色图标目录 /Graphics/Pictures/Actor/
如角色A的Id为1 那图标为 1.png
敌人图标目录 /Graphics/Pictures/Troop/
如敌人A的Id为1 那图标为 1.png
http://rpg.blue/static/image/smiley/yct/A059.gif中国字认识都不到一半,哪的心情学英语呀!
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
465
在线时间
915 小时
注册时间
2011-5-11
帖子
438
3
发表于 2012-12-22 13:49:37 | 只看该作者
修改脚本中的def create_rtabcp_gauge
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 生成战斗CP条
  3.   #--------------------------------------------------------------------------
  4.   def create_rtabcp_gauge
  5.     @cpgauge_back = Sprite.new(@viewport3)
  6.     @cpgauge_back.bitmap = Bitmap.new(200, 8)
  7.     @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 255, 0), Color.new(255, 0, 0))
  8.     @cpgauge_back.x = 16
  9.     @cpgauge_back.y = 16
  10.     # 各个角色生成其图标
  11.    @icons = {}
  12.    index=0
  13.     for iii in $game_party.members
  14.       @icons[iii] = Sprite.new(@viewport3)
  15.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/SL我方"+index.to_s+".png")
  16.       @icons[iii].ox = 12
  17.       @icons[iii].oy = 12
  18.       @icons[iii].x = 16
  19.       @icons[iii].y = 20
  20.       index+=1
  21.     end
  22.     index=0
  23.     for iii in $game_troop.members
  24.       @icons[iii] = Sprite.new(@viewport3)
  25.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/SL敌方"+index.to_s+".png")
  26.       @icons[iii].ox = 12
  27.       @icons[iii].oy = 12
  28.       @icons[iii].x = 16
  29.       @icons[iii].y = 20
  30.       index+=1
  31.     end
  32.   end
  

Graphics/Pictures/  目录中的图标文件按序号增加0-7
http://rpg.blue/static/image/smiley/yct/A059.gif中国字认识都不到一半,哪的心情学英语呀!
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
86 小时
注册时间
2012-10-27
帖子
16
4
 楼主| 发表于 2012-12-22 14:14:02 | 只看该作者
345912390 发表于 2012-12-22 13:49
修改脚本中的def create_rtabcp_gauge
#--------------------------------------------------------------- ...

我方角色似乎只能设置前八人啊?无法给25号角色替换(仍然是第0号战斗图)
地方角色没弄成功,一直是“SL敌方0”
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
465
在线时间
915 小时
注册时间
2011-5-11
帖子
438
5
发表于 2012-12-22 14:21:26 | 只看该作者
游系风 发表于 2012-12-22 14:14
我方角色似乎只能设置前八人啊?无法给25号角色替换(仍然是第0号战斗图)
地方角色没弄成功,一直是“SL ...

你想把它战斗时换人的脚本整合在一起?我没有战斗换人的脚本

我发的那个是以队伍为编号,并不是以角色ID 为编号。
如果以角色ID为编号,那个需要大量的图标文件
http://rpg.blue/static/image/smiley/yct/A059.gif中国字认识都不到一半,哪的心情学英语呀!
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
86 小时
注册时间
2012-10-27
帖子
16
6
 楼主| 发表于 2012-12-22 14:25:35 | 只看该作者
345912390 发表于 2012-12-22 14:21
你想把它战斗时换人的脚本整合在一起?我没有战斗换人的脚本

我发的那个是以队伍为编号,并不是以角色ID ...

不用战斗中换人,战前就换好了。
我想弄一个,除了主角外,其他同伴可以随便搭配的游戏(不同的角色,不同的脸)。
敌人的图标,是因为要区分敌方BOSS。
能把脚本改成根据ID来修改图标吗?
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
86 小时
注册时间
2012-10-27
帖子
16
7
 楼主| 发表于 2012-12-22 14:46:50 | 只看该作者
345912390 发表于 2012-12-22 14:40
修改脚本中def create_rtabcp_gauge
#-------------------------------------------------------------- ...

谢谢大神相助!!

点评

请问一下楼主弄明白了怎么给每个人加读条图标了嘛?  发表于 2014-3-10 22:34
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 14:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表