查看: 2086|回复: 9

[已经解决] 仿传说称号的脚本如何设置一个队伍有2个人不崩溃

[复制链接]
梦石
0
星屑
1153
在线时间
249 小时
注册时间
2014-8-27
回帖
10
发表于 2014-9-11 21:38:06 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 丿梁丶小柒 于 2014-10-6 10:36 编辑

[pre lang="ruby" line="1"]def construct_appe_data(actor_id)
    appe = []
    i = 0
    APPELLATION[actor_id].each { |v|
    info = APPE_INFO.new
    info.param = got_appe_param(actor_id, i)
    info.name = v[1]
    info.description = v[2]
    info.enable = (i == 0)
    appe = info
    i += 1}
    return appe
  end
end # Kien
module Kien
  module Command
    module_function
    def get_appellation(actor_id, id)
      $game_actors[actor_id].get_appellation(id)
      return true
    end
   
    def lose_appellation(actor_id, id)
      $game_actors[actor_id].lose_appellation(id)
      return true
    end
   
    def call_equip_appellation(actor_index = 1)
      $scene = Scene_Appellation.new(actor_index,0,1)
      return true
    end
   
    def have_appellation(actor_id, id, sid = 0)
      $game_switches[sid] = $game_actors[actor_id].appellation_list[id].enable
      return $game_actors[actor_id].appellation_list[id].enable
    end
   
    def equip_appellation(actor_id, id, sid = 0)
      $game_switches[sid] = ($game_actors[actor_id].appellation_id == id)
      return ($game_actors[actor_id].appellation_id == id)
    end

    def have_howmany_appellation(actor_id, vid = 0)
      n = 0
      for appe in $game_actors[actor_id].appellation_list
        if appe.enable == true
          n += 1
        else
          next
        end
      end
      $game_variables[vid] = n
      return n
    end
  end
end[/pre]
这个是仿传说称号的脚本我想问一下如何设置一个队伍有2个人不崩溃的怎么改

聪仔

梦石
0
星屑
6187
在线时间
3077 小时
注册时间
2013-12-26
回帖
3076
发表于 2014-9-12 13:01:57 | 显示全部楼层
你没有添加所加入的角色的称号,所以报错...
例如你要让2号角色加入,你需要在第40行加一句2号角色称号初始化...
  1. APPELLATION[2] = []
复制代码
然后还要为2号角色称号列表里添加内容,仿照1号角色的设置,比如这样...
  1. APPELLATION[2][0] = ["", "见习剑士", "还在修炼中的剑士"]
  2. APPELLATION[2][1] = ["HP5", "强壮", "表示你拥有强壮体制的称号"]
复制代码
都添加了就不会报错了...

评分

参与人数 1星屑 +120 收起 理由
丿梁丶小柒 + 120 认可答案

查看全部评分

聪聪全国第三帅...
他们都叫我【人赢聪】
我的RM能力雷达图:

回复

使用道具 举报

聪仔

梦石
0
星屑
6187
在线时间
3077 小时
注册时间
2013-12-26
回帖
3076
发表于 2014-9-11 21:43:27 | 显示全部楼层
这个脚本肯定是不完整的吧...能不能给个附带完整脚本的简易工程呢?让我们在问题工程上直接修改,也许更有效率的说...
聪聪全国第三帅...
他们都叫我【人赢聪】
我的RM能力雷达图:

回复

使用道具 举报

梦石
0
星屑
1153
在线时间
249 小时
注册时间
2014-8-27
回帖
10
 楼主| 发表于 2014-9-11 21:47:51 | 显示全部楼层
本帖最后由 丿梁丶小柒 于 2014-9-12 20:34 编辑

[pre lang="ruby" line="1"]#============================================================================
# ☆ 仿传说称号系统。
#    由feizhaodan制作。
#    发布于66RPG
#    http://rpg.blue/
#    版本号: 1.2.3
#    添加内容:
#    1.2.3
#     根据皮卡星的建议,增大装备称号确认窗口的Z值并添加$imported
#    1.2.2
#     1.在升级时重新计算百分比增加的属性量。
#     2.在失去称号时若失去的是当前装备,则将称号ID改回默认,并重设属性。
#     3.增加新方法:refresh_appellation。
#    1.2.1
#     修正qwrffdtqfsd 提出的在满HPMP状态下降低HPMP上限会使
#     HPMP超过上限。
#    1.2.0
#     修正若称号说明超过1行,显示不完整。
#    1.1.0
#     增加从状态画面进入各角色的称号装备界面的功能。
#    2011/10/22
#    转载时请连同这里一起转
#============================================================================
#==============================================================================
# ■ Kien::Appellation
#------------------------------------------------------------------------------
#  称号系统。(新模块)(设置内容)
#==============================================================================
module Kien
module Appellation
  
  
  # 不要该这里。
  APPELLATION = []
  
  # 从这里开始设置。
  # 先在这里按例子添加。
  # 格式:
  # APPELLATION[actor_id] = []
  # 在actor_id内填入你的角色ID。把所有你的游戏里的角色都添加一次。
  APPELLATION[1] =[]
  
  # 这里开始一个一个设置。
  # 格式: APPELLATION[actor_id][id] = ["STn[%]|STn[%]", "name", "str"]
  # actor_id填入要设置的角色ID
  # id填入要设置的称号ID。0为预设。
  # ["ST=n|ST=n", "str"]
  # ST表示装备此称号时增加的属性(ATK,DEF,AGI,SPI,HP,SP,EXP,GOLD)
  # 用"|"隔开。可以填写多个。
  # n表示增加量,%可填可不填,填的场合为百分比,不填为那个数量。可以是负数。
  # 其中EXP和GOLD表示获取时增加的量,固定为%。
  # name表示这个称号的名字
  # str表示这个称号的说明。
  # 三个内容的""要留着。
  # 例:
  # 一个没有属性加成的预设称号
  APPELLATION[1][0] = ["", "见习剑士", "还在修炼中的剑士"]
  
  # 一个增加5点HP的一号称号
  APPELLATION[1][1] = ["HP5", "强壮", "表示你拥有强壮体制的称号"]
  
  # 一个增加10点ATK,5点DEF的称号
  APPELLATION[1][2] = ["ATK10|DEF5", "剑士", "已经完成修炼的剑士"]
  
  # 一个将所有属性乘10倍的称号。
  APPELLATION[1][3] = ["HP1000%|MP1000%|ATK1000%|DEF1000%|SPI1000%|AGI1000%", "挑战者", "给敢于挑战未知的人的称号。"]

  # 选项添加在哪,
  # 1为菜单,2为状态窗口内,0为不使用。
  ADD_APPELLATION_COMMAND = 2
  
  # 选项名称。
  APPELLATION_COMMANDNAME = "称号"
  
  # 称号属性名
  APPELLATION_NAME = "称号"
  
  # 未开放称号名
  UNENABLE_NAME = "-------"
end
end

#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼
# 已下为脚本。 不会编脚本的修改之前请备份。
#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼

$imported = {} if $imported == nil
$imported["Tales_Appellation"] = true

module Kien
module Regexp
  module Appellation
    # 称号附加属性判定
    STATUS = /(HP|MP|ATK|DEF|SPI|AGI|EXP|GOLD)?([\+\-]?\d+)([%])?/i
  end # Appellation
end # Regexp
end # Kien

module Kien::Appellation
  
  APPE_INFO = Struct.new("Appe_Info", :param, :name, :description, :enable)
  
  module_function
  #--------------------------------------------------------------------------
  # ● 获取称号属性
  #     actor_id : 角色 ID
  #     id       : 称号 ID
  #--------------------------------------------------------------------------
  def got_appe_param(actor_id, id)
    param = []
    APPELLATION[actor_id][id][0].split(/\|/).each{ |str|
    case str
    when Kien::Regexp::Appellation::STATUS
      param.push [$1, $2.to_i, $3]
    end
    }
    return param
  end
  #--------------------------------------------------------------------------
  # ● 将称号属性构建体化
  #     actor_id : 角色 ID
  #--------------------------------------------------------------------------
  def construct_appe_data(actor_id)
    appe = []
    i = 0
    APPELLATION[actor_id].each { |v|
    info = APPE_INFO.new
    info.param = got_appe_param(actor_id, i)
    info.name = v[1]
    info.description = v[2]
    info.enable = (i == 0)
    appe = info
    i += 1
    }
    return appe
  end
end # Kien
module Kien
  module Command
    module_function
    def get_appellation(actor_id, id)
      $game_actors[actor_id].get_appellation(id)
      return true
    end
   
    def lose_appellation(actor_id, id)
      $game_actors[actor_id].lose_appellation(id)
      return true
    end
   
    def call_equip_appellation(actor_index = 1)
      $scene = Scene_Appellation.new(
          actor_index,
          0,
          1)
      return true
    end
   
    def have_appellation(actor_id, id, sid = 0)
      $game_switches[sid] = $game_actors[actor_id].appellation_list[id].enable
      return $game_actors[actor_id].appellation_list[id].enable
    end
   
    def equip_appellation(actor_id, id, sid = 0)
      $game_switches[sid] = ($game_actors[actor_id].appellation_id == id)
      return ($game_actors[actor_id].appellation_id == id)
    end

    def have_howmany_appellation(actor_id, vid = 0)
      n = 0
      for appe in $game_actors[actor_id].appellation_list
        if appe.enable == true
          n += 1
        else
          next
        end
      end
      $game_variables[vid] = n
      return n
    end
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  执行事件命令的解释器。本类在 Game_Map 类、Game_Troop 类、与
# Game_Event 类的内部使用。
#==============================================================================

class Game_Interpreter
include Kien::Command
end

#==============================================================================
# ■ Vocab
#------------------------------------------------------------------------------
#  定义了用语和信息。将部分资料定义为常量。用语部分来自于$data_system。
#==============================================================================

module Vocab
  def self.appellation
    return Kien::Appellation::APPELLATION_NAME
  end
  
  def self.appellation_command_name
    return Kien::Appellation::APPELLATION_COMMANDNAME
  end
end
#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼
# 华丽的分割线
#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼

#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  处理角色的类。本类在 Game_Actors 类 ($game_actors) 的内部使用、
# Game_Party 类请参考 ($game_party) 。
#==============================================================================

class Game_Actor < Game_Battler
  
    APPE_INFO = Struct.new("Appe_Info", :param, :name, :description, :enable)
  alias appellation_setup setup
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :appellation_id
  attr_reader   :appe_gold
  #--------------------------------------------------------------------------
  # ● 设置
  #     actor_id : 角色 ID
  #--------------------------------------------------------------------------
  def setup(actor_id)
    @appe_hp = 0
    @appe_mp = 0
    @appe_atk = 0
    @appe_def = 0
    @appe_spi = 0
    @appe_agi = 0
    @appe_gold = 0
    @appe_exp = 0
    appellation_setup(actor_id)
    @appellation_list = Kien::Appellation.construct_appe_data(actor_id)
    @appellation_id = 0
    create_appe_param
  end
  #--------------------------------------------------------------------------
  # ● 获取称号列表
  #--------------------------------------------------------------------------
  def appellation_list
    return @appellation_list
  end
  #--------------------------------------------------------------------------
  # ● 获取称号内容
  #--------------------------------------------------------------------------
  def appellation
    return @appellation_list[@appellation_id]
  end
  #--------------------------------------------------------------------------
  # ● 获取新称号
  #--------------------------------------------------------------------------
  def get_appellation(id)
    @appellation_list[id].enable = true
  end
  #--------------------------------------------------------------------------
  # ● 失去称号
  #--------------------------------------------------------------------------
  def lose_appellation(id)
    return if id == 0
    @appellation_list[id].enable = false
    if @appellation_id == id
      @appllation_id = 0
      refresh_appellation
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新称号
  #--------------------------------------------------------------------------
  def refresh_appellation
    create_appe_param
    @mp = [@mp, self.maxmp].min
    @hp = [@hp, self.maxhp].min
  end
  #--------------------------------------------------------------------------
  # ● 更换称号
  #--------------------------------------------------------------------------
  def change_appellation(appe_id)
    @appellation_id = appe_id
    refresh_appellation
  end
  #--------------------------------------------------------------------------
  # ● 获取称号内容
  #--------------------------------------------------------------------------
  def create_appe_param
    @appe_hp = 0
    @appe_mp = 0
    @appe_atk = 0
    @appe_def = 0
    @appe_spi = 0
    @appe_agi = 0
    @appe_gold = 0
    @appe_exp = 0
    if appellation.param.empty?
    else
      for i in appellation.param
        case i[0]
        when /HP/i
          @appe_hp = i[1]
          @appe_hpper = i[2] == nil ? false : true
        when /MP/i
          @appe_mp = i[1]
          @appe_mpper = i[2] == nil ? false : true
        when /ATK/i
          @appe_atk = i[1]
          @appe_atkper = i[2] == nil ? false : true
        when /DEF/i
          @appe_def = i[1]
          @appe_defper = i[2] == nil ? false : true
        when /SPI/i
          @appe_spi = i[1]
          @appe_spiper = i[2] == nil ? false : true
        when /AGI/i
          @appe_agi = i[1]
          @appe_agiper = i[2] == nil ? false : true
        when /GOLD/i
          @appe_gold = i[1]
          @appe_goldper = i[2] == nil ? false : true
        when /EXP/i
          @appe_exp = i[1]
          @appe_expper = i[2] == nil ? false : true
        else
          next
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取基本体力最大值
  #--------------------------------------------------------------------------
  alias appellation_base_maxhp base_maxhp
  def base_maxhp
    n = appellation_base_maxhp
    if @appe_hpper == true
      n += actor.parameters[0, @level] * @appe_hp / 100
    else
      n += @appe_hp
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取基本魔力最大值
  #--------------------------------------------------------------------------
  alias appellation_base_maxmp base_maxmp
  def base_maxmp
    n = appellation_base_maxmp
    if @appe_mpper == true
      n += actor.parameters[1, @level] * @appe_mp / 100
    else
      n += @appe_mp
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取基本攻击力
  #--------------------------------------------------------------------------
  alias appellation_base_atk base_atk
  def base_atk
    n = appellation_base_atk
    if @appe_atkper == true
      n += actor.parameters[2, @level] * @appe_atk / 100
    else
      n += @appe_atk
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取基本防御力
  #--------------------------------------------------------------------------
  alias appellation_base_def base_def
  def base_def
    n = appellation_base_def
    if @appe_defper == true
      n += actor.parameters[3, @level] * @appe_def / 100
    else
      n += @appe_def
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取基本精神力
  #--------------------------------------------------------------------------
  alias appellation_base_spi base_spi
  def base_spi
    n = appellation_base_spi
    if @appe_spiper == true
      n += actor.parameters[4, @level] * @appe_spi / 100
    else
      n += @appe_spi
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取基本敏捷
  #--------------------------------------------------------------------------
  alias appellation_base_agi base_agi
  def base_agi
    n = appellation_base_agi
    if @appe_agiper == true
      n += actor.parameters[5, @level] * @appe_agi / 100
    else
      n += @appe_agi
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取经验(获取双倍经验值用)
  #     exp  : 经验值量
  #     show : 显示等级提示标志
  #--------------------------------------------------------------------------
  alias appellation_gain_exp gain_exp
  def gain_exp(exp, show)
    exp += exp * @appe_exp / 100
    appellation_gain_exp(exp, show)
  end
  #--------------------------------------------------------------------------
  # ● 升级
  #--------------------------------------------------------------------------
  alias appellation_level_up level_up
  def level_up
    appellation_level_up
    refresh_appellation
  end
end
#==============================================================================
# ■ Game_Troop
#------------------------------------------------------------------------------
#  处理敌人队伍和战斗相关资料的类,也可执行如战斗事件管理之类的功能。
# 本类的实例请参考 $game_troop。
#==============================================================================

class Game_Troop < Game_Unit
  alias appellation_gold_total gold_total
  #--------------------------------------------------------------------------
  # ● 计算金钱总数
  #--------------------------------------------------------------------------
  def gold_total
    gold = appellation_gold_total
    per = $game_party.appe_gold_per
    gold += gold * per / 100
    return gold
  end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  处理同伴的类。包含金钱以及物品的信息。本类的实例请参考 $game_party。
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ● 计算称号金钱获得影响量
  #--------------------------------------------------------------------------
  def appe_gold_per
    per = 0
    for member in members
      per += member.appe_gold
    end
    return per
  end
end

#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼
# 华丽的分割线2
# 以下插入指令的方法从KGC的脚本内取出。版权归KGC
#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼
#==============================================================================
# ■ Window_Command
#==============================================================================

class Window_Command < Window_Selectable
  unless method_defined?(:add_command)
  #--------------------------------------------------------------------------
  # ○ コマンドを追加
  #    追加した位置を返す
  #--------------------------------------------------------------------------
  def add_command(command)
    @commands << command
    @item_max = @commands.size
    item_index = @item_max - 1
    refresh_command
    draw_item(item_index)
    return item_index
  end
  #--------------------------------------------------------------------------
  # ○ コマンドをリフレッシュ
  #--------------------------------------------------------------------------
  def refresh_command
    buf = self.contents.clone
    self.height = [self.height, row_max * WLH + 32].max
    create_contents
    self.contents.blt(0, 0, buf, buf.rect)
    buf.dispose
  end
  #--------------------------------------------------------------------------
  # ○ コマンドを挿入
  #--------------------------------------------------------------------------
  def insert_command(index, command)
    @commands.insert(index, command)
    @item_max = @commands.size
    refresh_command
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ コマンドを削除
  #--------------------------------------------------------------------------
  def remove_command(command)
    @commands.delete(command)
    @item_max = @commands.size
    refresh
  end
  end
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================

class Scene_Menu < Scene_Base
  if Kien::Appellation::ADD_APPELLATION_COMMAND == 1
  #--------------------------------------------------------------------------
  # ● コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias create_command_window_appellation create_command_window
  def create_command_window
    create_command_window_appellation
    @command_appellation_index =
      @command_window.add_command(Vocab.appellation_command_name)
    if @command_window.oy > 0
      @command_window.oy -= Window_Base::WLH
    end
    @command_window.index = @menu_index
  end
  end
  #--------------------------------------------------------------------------
  # ● コマンド選択の更新
  #--------------------------------------------------------------------------
  alias update_command_selection_appellation update_command_selection
  def update_command_selection
    call_distribute_parameter_flag = false
    if Input.trigger?(Input::C)
      case @command_window.index
      when @command_appellation_index  # パラメータ振り分け
        call_appellation_flag = true
      end
    end

    # パラメータ振り分け画面に移行
    if call_appellation_flag
      if $game_party.members.size == 0
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      start_actor_selection
      return
    end

    update_command_selection_appellation
  end
  #--------------------------------------------------------------------------
  # ● アクター選択の更新
  #--------------------------------------------------------------------------
  alias update_actor_selection_appellation update_actor_selection
  def update_actor_selection
    if Input.trigger?(Input::C)
      $game_party.last_actor_index = @status_window.index
      Sound.play_decision
      case @command_window.index
      when @command_appellation_index  # 更换称号。
        $scene = Scene_Appellation.new(
          @status_window.index,
          @command_appellation_index,
          Kien::Appellation::ADD_APPELLATION_COMMAND)
        return
      end
    end

    update_actor_selection_appellation
  end
end
#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼
# 华丽的分割线3号
# 以下回归原创
#★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼★☆●○▲△■□▼
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  游戏中全部窗口的超级类。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 绘制角色称号
  #     actor : 角色
  #     x     : 描画目标 X 坐标
  #     y     : 描画目标 Y 坐标
  #--------------------------------------------------------------------------
  def draw_actor_appellation(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 108, WLH, actor.appellation.name)
  end
end
#==============================================================================
# ■ Window_AppellationStatus
#------------------------------------------------------------------------------
#  更换称号时显示角色能力值变化的窗口。
#==============================================================================

class Window_AppellationStatus < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     x      : 窗口 X 座标
  #     y      : 窗口 Y 座标
  #     actor  : 角色
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 208, 316)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_name(@actor, 4, 0)
    draw_actor_face(@actor, 0, WLH * 1)
    draw_actor_appellation(@actor, 0, WLH * 2 + 72)
    draw_parameter(0, WLH * 3 + 72, 4)
    draw_parameter(0, WLH * 4 + 72, 5)
    draw_parameter(0, WLH * 5 + 72, 0)
    draw_parameter(0, WLH * 6 + 72, 1)
    draw_parameter(0, WLH * 7 + 72, 2)
    draw_parameter(0, WLH * 8 + 72, 3)
  end
  #--------------------------------------------------------------------------
  # ● 设置装备後的能力值
  #     new_atk : 装备後的攻击力
  #     new_def : 装备後的防御力
  #     new_spi : 装备後的精神力
  #     new_agi : 装备後的敏捷
  #--------------------------------------------------------------------------
  def set_new_parameters(new_atk, new_def, new_spi, new_agi, new_hp, new_mp)
    if @new_atk != new_atk or @new_def != new_def or
       @new_spi != new_spi or @new_agi != new_agi
      @new_atk = new_atk
      @new_def = new_def
      @new_spi = new_spi
      @new_agi = new_agi
      @new_hp = new_hp
      @new_mp = new_mp
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取装备後的能力值文字颜色
  #     old_value : 装备前的能力值
  #     new_value : 装备後的能力值
  #--------------------------------------------------------------------------
  def new_parameter_color(old_value, new_value)
    if new_value > old_value      # 增强
      return power_up_color
    elsif new_value == old_value  # 不变
      return normal_color
    else                          # 减弱
      return power_down_color
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制能力值
  #     x    : 绘制点 X 座标
  #     y    : 绘制点 Y 座标
  #     type : 能力值 (0:攻击力、1:防御力、2:精神力、3:敏捷)
  #--------------------------------------------------------------------------
  def draw_parameter(x, y, type)
    case type
    when 0
      name = Vocab::atk
      value = @actor.atk
      new_value = @new_atk
    when 1
      name = Vocab::def
      value = @actor.def
      new_value = @new_def
    when 2
      name = Vocab::spi
      value = @actor.spi
      new_value = @new_spi
    when 3
      name = Vocab::agi
      value = @actor.agi
      new_value = @new_agi
    when 4
      name = "最大" + Vocab::hp
      value = @actor.maxhp
      new_value = @new_hp
    when 5
      name = "最大" + Vocab::mp
      value = @actor.maxmp
      new_value = @new_mp
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x + 4, y, 80, WLH, name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 90, y, 30, WLH, value, 2)
    if new_value != nil
      self.contents.font.color = system_color
      self.contents.draw_text(x + 122, y, 20, WLH, ">", 1)
      self.contents.font.color = new_parameter_color(value, new_value)
      self.contents.draw_text(x + 142, y, 30, WLH, new_value, 2)
    end
  end
end
#==============================================================================
# ■ Window_SelectAppellation
#------------------------------------------------------------------------------
#  选择称号的窗口。
#==============================================================================

class Window_SelectAppellation < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor  : 角色
  #--------------------------------------------------------------------------
  def initialize(actor)
    @actor = actor
    super(208, 0, 336, 316)
    @column_max = 2
    self.index = 0
    self.active = true
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    @appellation_list = @actor.appellation_list
    @item_max = @appellation_list.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取称号
  #--------------------------------------------------------------------------
  def appellation
    return @appellation_list[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    appe = @appellation_list[index]
    if appe.enable == true
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = 255
      self.contents.draw_text(rect, appe.name, 1)
    else
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = 128
      self.contents.draw_text(rect, Kien::Appellation::UNENABLE_NAME, 1)
    end
  end
end
#==============================================================================
# ■ Window_AppellationData
#------------------------------------------------------------------------------
#  称号说明。
#==============================================================================

class Window_AppellationData < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(0, 316, 544, 100)
    @appe = nil
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update(appe)
    super()
    if appe != @appe
      @appe = appe
      self.contents.clear
      if @appe.enable == true
        self.contents.draw_text(0, WLH * 0, 544, WLH, @appe.description)
        draw_effect
      else
        self.contents.draw_text(0, WLH * 0, 544, WLH, "你还没有得到这个称号")
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def draw_effect
    if @appe.param == nil
      self.contents.draw_text(0, WLH * 1, 544, WLH, "无属性")
    else
      x = 0
      line = 1
      for effect in @appe.param
        case effect[0]
        when /HP/i
          param = "最大" + Vocab::hp
        when /MP/i
          param = "最大" + Vocab::mp
        when /ATK/i
          param = Vocab::atk
        when /DEF/i
          param = Vocab::def
        when /AGI/i
          param = Vocab::agi
        when /SPI/i
          param = Vocab::spi
        when /EXP/i
          param = "获得经验"
        when /GOLD/i
          param = "获得金钱"
        end
        word = effect[1] > 0 ? "+" + effect[1].to_i.to_s : effect[1].to_i.to_s
        word = effect[2] == nil ? word : word + "%"
        width = contents.text_size(param).width
        width += contents.text_size(word).width
        if x + width > 544 and line == 1
          line = 2
          x = 0
        end
        if x + width > 544 and line == 2
          break
        end
        self.contents.draw_text(x, WLH * line, width, WLH, param)
        self.contents.draw_text(x, WLH * line, width, WLH, word, 2)
        x += width + 32
      end
    end
  end
end

#==============================================================================
# ■ Window_Status
#------------------------------------------------------------------------------
#  显示状态画面、完全规格的状态窗口。
#==============================================================================

class Window_Status < Window_Base
  alias appellation_refresh refresh
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    appellation_refresh
    draw_actor_appellation(@actor, 256, 0)
  end
end

#==============================================================================
# ■ Scene_Status
#------------------------------------------------------------------------------
#  处理状态画面的类。
#==============================================================================

class Scene_Status < Scene_Base
if Kien::Appellation::ADD_APPELLATION_COMMAND == 2
  alias appellation_start start
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    appellation_start
    create_command_window
  end
  #--------------------------------------------------------------------------
  # ● 生成命令窗口
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = "变更称号"
    s2 = "取消"
    @command_window = Window_Command.new(128, [s1, s2])
    @command_window.active = false
    @command_window.openness = 0
    @command_window.x = 544 / 2 - 128 / 2
    @command_window.y = 416 / 2 - (Window_Base::WLH * 2 + 32) / 2
  end
  alias appellation_terminate terminate
  #--------------------------------------------------------------------------
  # ● 结束处理
  #--------------------------------------------------------------------------
  def terminate
    appellation_terminate
    @command_window.dispose
  end
  alias appellation_update update
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    @command_window.update
    if @command_window.active
      if Input.trigger?(Input::C)
        Sound.play_decision
        $scene = Scene_Appellation.new(@actor_index)
      elsif Input.trigger?(Input::B)
        Sound.play_cancel
        @command_window.close
        @command_window.active = false
        return
      end
    else
      if Input.trigger?(Input::C)
        Sound.play_decision
        @command_window.open
        @command_window.active = true
      return
      end
      appellation_update
    end
  end
end
end
#==============================================================================
# ■ Scene_Appellation
#------------------------------------------------------------------------------
#  处理更换称号的类。
#==============================================================================

class Scene_Appellation < Scene_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor_index : 角色 ID
  #     menu_index  : 命令窗口光标初始位置
  #     host_scene  : 上个场景(0..地图, 1..菜单, 2..状态画面)
  #--------------------------------------------------------------------------
  def initialize(actor_index = 1, menu_index = 0, host_scene = Kien::Appellation::ADD_APPELLATION_COMMAND)
    @actor_index = actor_index
    @menu_index = menu_index
    @host_scene = host_scene
  end
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    create_menu_background
    @actor = $game_party.members[@actor_index]
    @appellation_status = Window_AppellationStatus.new(@actor)
    @appellation_select = Window_SelectAppellation.new(@actor)
    @appellation_data = Window_AppellationData.new
    create_command_window
  end
  #--------------------------------------------------------------------------
  # ● 生成命令窗口
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = "装备称号"
    s2 = "取消"
    @command_window = Window_Command.new(128, [s1, s2])
    @command_window.active = false
    @command_window.openness = 0
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    @appellation_status.update
    @appellation_select.update
    @appellation_data.update(@appellation_select.appellation)
    @command_window.update
    if @appellation_select.active
      if Input.trigger?(Input::B)
        Sound.play_cancel
        return_scene
      elsif Input.trigger?(Input::C)
        Sound.play_decision
        show_command_window
      end
    elsif @command_window.active
      if Input.trigger?(Input::B)
        Sound.play_cancel
        close_command_window
      elsif Input.trigger?(Input::C)
        case @command_window.index
        when 0
          if @appellation_select.index == @actor.appellation_id or @appellation_select.appellation.enable == false
            Sound.play_buzzer
            return
          else
            Sound.play_decision
            change_appellation
          end
        when 1
          Sound.play_decision
          close_command_window
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 结束处理
  #--------------------------------------------------------------------------
  def terminate
    @appellation_status.dispose
    @appellation_select.dispose
    @appellation_data.dispose
    @command_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 显示命令窗口
  #--------------------------------------------------------------------------
  def show_command_window
    @command_window.x = @appellation_select.index % 2 == 0 ? 208 : 376
    @command_window.y = @appellation_select.item_rect(@appellation_select.index).y
    if @command_window.y > Window_Base::WLH * 2 + 32
      @command_window.y -= Window_Base::WLH * 2 + 32
    else
      @command_window.y += Window_Base::WLH
    end
    @command_window.z = 100
    @command_window.open
    if @appellation_select.index == @actor.appellation_id or @appellation_select.appellation.enable == false
      @command_window.draw_item(0, false)
    else
      @command_window.draw_item(0, true)
    end
    @command_window.active = true
    @appellation_select.active = false
  end
  #--------------------------------------------------------------------------
  # ● 关闭命令窗口
  #--------------------------------------------------------------------------
  def close_command_window
    @command_window.close
    @command_window.active = false
    @appellation_select.active = true
  end
  #--------------------------------------------------------------------------
  # ● 更换称号
  #--------------------------------------------------------------------------
  def change_appellation
    @actor.change_appellation(@appellation_select.index)
    @appellation_status.refresh
    close_command_window
  end
  #--------------------------------------------------------------------------
  # ● 回到原画面
  #--------------------------------------------------------------------------
  def return_scene
    if @host_scene == 1
      $scene = Scene_Menu.new(@menu_index)
    elsif @host_scene == 2
      $scene = Scene_Status.new(@actor_index)
    else
      $scene = Scene_Map.new
    end
  end
end
#============================================================================
# ☆ 仿传说称号系统。
#    由feizhaodan制作。
#    发布于66RPG
#    http://rpg.blue/
#    版本号: 1.2.3
#    2011/12/11
#    转载时请连同这里一起转
#============================================================================[/pre]
回复

使用道具 举报

梦石
0
星屑
1153
在线时间
249 小时
注册时间
2014-8-27
回帖
10
 楼主| 发表于 2014-9-11 21:49:34 | 显示全部楼层
正太君 发表于 2014-9-11 21:43
这个脚本肯定是不完整的吧...能不能给个附带完整脚本的简易工程呢?让我们在问题工程上直接修改,也许更有 ...

脚本发了请大神帮忙看看

点评

发脚本用代码框啊<>魂淡  发表于 2014-9-12 14:24
把带有这个脚本的新建问题工程发布一下,我也方便修改呢...  发表于 2014-9-11 21:57
回复

使用道具 举报

聪仔

梦石
0
星屑
6187
在线时间
3077 小时
注册时间
2013-12-26
回帖
3076
发表于 2014-9-11 21:56:13 | 显示全部楼层
这么长的脚本,这样发布会出问题的呢,请把他放到一个新建工程里面...
测试这个新建工程如果出现你说的BUG,那就就证明脚本有问题,如果没问题,说明脚本和你的工程不兼容...
如果能说说怎么操作才会操作就好了,如果能把报错的截图给我们就更好了呀...你提供的资料越全面,越有利于问题的解决,毕竟这些脚本我们都没有使用过,这么长也没办法认真去看...
聪聪全国第三帅...
他们都叫我【人赢聪】
我的RM能力雷达图:

回复

使用道具 举报

梦石
0
星屑
1153
在线时间
249 小时
注册时间
2014-8-27
回帖
10
 楼主| 发表于 2014-9-11 22:08:37 | 显示全部楼层
正太君 发表于 2014-9-11 21:56
这么长的脚本,这样发布会出问题的呢,请把他放到一个新建工程里面...
测试这个新建工程如果出现你说的BUG ...

APPELLATION[actor_id].each { |v|
    info = APPE_INFO.new
主要是这句话里面each出了问题队伍一个人时没事2个人就崩溃了
def construct_appe_data(actor_id)
    appe = []
    i = 0
    APPELLATION[actor_id].each { |v|
    info = APPE_INFO.new
    info.param = got_appe_param(actor_id, i)
    info.name = v[1]
    info.description = v[2]
    info.enable = (i == 0)
    appe = info
    i += 1
    }

点评

发代码用代码框啊<>不传范例。xd触都救不了你。  发表于 2014-9-12 09:21
这样说真的没用的...又不知道报错是什么,毕竟我也不是什么大神...上传个简单的工程我看一看就好了呢...  发表于 2014-9-11 22:11
回复

使用道具 举报

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
发表于 2014-9-12 07:58:59 | 显示全部楼层
把你的工程传上来
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890
回复

使用道具 举报

无限の剣制

梦石
0
星屑
10445
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2014-9-12 09:24:46 | 显示全部楼层
APPELLATION[   你设置好没,
回复

使用道具 举报

梦石
0
星屑
1153
在线时间
249 小时
注册时间
2014-8-27
回帖
10
 楼主| 发表于 2014-9-12 14:59:38 | 显示全部楼层
正太君 发表于 2014-9-12 13:01
你没有添加所加入的角色的称号,所以报错...
例如你要让2号角色加入,你需要在第40行加一句2号角色称号初始 ...

我明白了谢谢大神
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部