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

Project1

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

[已经解决] 称号选择问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
79 小时
注册时间
2007-2-11
帖子
140
1
发表于 2012-5-29 21:05:32 | 显示全部楼层
本帖最后由 asd11000 于 2012-5-29 21:23 编辑

给你写了个。。
范例请无视里面的史莱姆,那是给别个的范例。。
添加新的称号:$game_actors[成员ID].get_new_nickname("真心人,这里是称号名称","灰常真心的人,这里是称号介绍")

我是放在菜单里调用的,因为要先选择成员,然后每个成员有相应的称号,不同成员的称号不能互相使用。
所以要给以下2个方法添加几句(红字):
1 Scene_Menu
  #--------------------------------------------------------------------------
  # ● 生成指令窗口
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_MenuCommand.new
    @command_window.set_handler(:item,      method(:command_item))
    @command_window.set_handler(:skill,     method(:command_personal))
    @command_window.set_handler(:equip,     method(:command_personal))
    @command_window.set_handler(:status,    method(:command_personal))
    @command_window.set_handler(:nickname,  method(:command_personal))
    @command_window.set_handler(:formation, method(:command_formation))
    @command_window.set_handler(:save,      method(:command_save))
    @command_window.set_handler(:game_end,  method(:command_game_end))
    @command_window.set_handler(:cancel,    method(:return_scene))
  end


  #--------------------------------------------------------------------------
  # ● 个人指令“确定”
  #--------------------------------------------------------------------------
  def on_personal_ok
    case @command_window.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :equip
      SceneManager.call(Scene_Equip)
    when :status
      SceneManager.call(Scene_Status)
    when :nickname
      SceneManager.call(Scene_Nickname)

    end
  end

2 Window_MenuCommand
  #--------------------------------------------------------------------------
  # ● 向指令列表添加主要的指令
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command(Vocab::item,   :item,   main_commands_enabled)
    add_command(Vocab::skill,  :skill,  main_commands_enabled)
    add_command(Vocab::equip,  :equip,  main_commands_enabled)
    add_command(Vocab::status, :status, main_commands_enabled)
    add_command("称号",   :nickname,   main_commands_enabled)
  end

以下是代码部分
  1. #encoding:utf-8
  2. class Nickname
  3.   attr_reader :name
  4.   attr_reader :description
  5.   #--------------------------------------------------------------------------
  6.   # ● 初始化对象
  7.   #--------------------------------------------------------------------------
  8.   def initialize(name, description)
  9.     @name = name
  10.     @description = description
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # ● 称号菜单中的显示
  14.   #--------------------------------------------------------------------------
  15.   def default_nickname?(name)
  16.     return @name == name
  17.   end
  18. end
  19. #==============================================================================
  20. # ■ Game_Actor
  21. #------------------------------------------------------------------------------
  22. #  管理角色的类。
  23. #   本类在 Game_Actors 类 ($game_actors) 的内部使用。
  24. #   具体使用请查看 Game_Party 类 ($game_party) 。
  25. #==============================================================================
  26. class Game_Actor < Game_Battler
  27.   #--------------------------------------------------------------------------
  28.   # ● 初始化对象
  29.   #--------------------------------------------------------------------------
  30.   alias old_initialize initialize
  31.   def initialize(actor_id)
  32.     old_initialize(actor_id)
  33.     @nickname_list = []
  34.     @nickname_list.push(Nickname.new(@nickname,"默认称号"))
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 获得新称号
  38.   #--------------------------------------------------------------------------
  39.   def get_new_nickname(nickname,description)
  40.     @nickname_list.push(Nickname.new(nickname,description)) if !nickname?(nickname)
  41.   end  
  42.   #--------------------------------------------------------------------------
  43.   # ● 称号是否存在
  44.   #--------------------------------------------------------------------------
  45.   def nickname?(nickname)
  46.     @nickname_list.each do |name|
  47.       return true if nickname == name
  48.     end
  49.     return false
  50.   end  
  51.   #--------------------------------------------------------------------------
  52.   # ● 设置称号
  53.   #--------------------------------------------------------------------------
  54.   def set_nickname(index)
  55.     @nickname = @nickname_list[index].name
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 获得所有称号
  59.   #--------------------------------------------------------------------------
  60.   def get_nickname_list
  61.     @nickname_list
  62.   end
  63. end
  64. #==============================================================================
  65. # ■ Scene_Nickname
  66. #------------------------------------------------------------------------------
  67. #  称号画面
  68. #==============================================================================

  69. class Scene_Nickname < Scene_ItemBase
  70.   #--------------------------------------------------------------------------
  71.   # ● 开始处理
  72.   #--------------------------------------------------------------------------
  73.   def start
  74.     super
  75.     create_help_window
  76.     create_status_window
  77.     create_names_window
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 生成状态窗口
  81.   #--------------------------------------------------------------------------
  82.   def create_status_window
  83.     y = @help_window.height
  84.     @status_window = Window_NicknameStatus.new(0, y)
  85.     @status_window.viewport = @viewport
  86.     @status_window.actor = @actor
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 生成称号窗口
  90.   #--------------------------------------------------------------------------
  91.   def create_names_window
  92.     wy = @status_window.y + @status_window.height
  93.     wh = Graphics.height - wy
  94.     @item_window = Window_Nickname.new(0, wy, Graphics.width, wh)
  95.     @item_window.set_actor(@actor)
  96.     @item_window.viewport = @viewport
  97.     @item_window.help_window = @help_window
  98.     @item_window.refresh
  99.     @item_window.activate
  100.     @item_window.select_last
  101.     @item_window.set_handler(:ok,     method(:on_item_ok))
  102.     @item_window.set_handler(:cancel, method(:return_scene))
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 称号“确定”
  106.   #--------------------------------------------------------------------------
  107.   def on_item_ok
  108.     @item_window.set_nickname(item)
  109.     @status_window.refresh
  110.     activate_item_window
  111.   end
  112. end
  113. #==============================================================================
  114. # ■ Window_Nickname
  115. #------------------------------------------------------------------------------
  116. #  称号画面中,显示已获得称号的窗口。
  117. #==============================================================================

  118. class Window_Nickname < Window_Selectable
  119.   #--------------------------------------------------------------------------
  120.   # ● 初始化对象
  121.   #--------------------------------------------------------------------------
  122.   def initialize(x, y, width, height)
  123.     super
  124.     @data = []
  125.     @actor = nil
  126.     @default_name = ""
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 获取列数
  130.   #--------------------------------------------------------------------------
  131.   def col_max
  132.     return 2
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 设置当前角色
  136.   #--------------------------------------------------------------------------
  137.   def set_actor(actor)
  138.     @actor = actor
  139.     @default_name = actor.nickname
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 设置当前称号
  143.   #--------------------------------------------------------------------------
  144.   def set_nickname(item)
  145.     @default_name = item.name
  146.     @actor.nickname = item.name
  147.     refresh
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 获取项目数
  151.   #--------------------------------------------------------------------------
  152.   def item_max
  153.     @data ? @data.size : 1
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 获取任务
  157.   #--------------------------------------------------------------------------
  158.   def item
  159.     @data && index >= 0 ? @data[index] : nil
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ● 获取选择称号的有效状态
  163.   #--------------------------------------------------------------------------
  164.   def enable?(index)
  165.     !@data[index].default_nickname?(@default_name)
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 生成称号列表
  169.   #--------------------------------------------------------------------------
  170.   def make_item_list
  171.     @data = @actor.get_nickname_list
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 返回上一个选择的位置
  175.   #--------------------------------------------------------------------------
  176.   def select_last
  177.     select(0)
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 绘制项目
  181.   #--------------------------------------------------------------------------
  182.   def draw_item(index)
  183.     item = @data[index]
  184.     if item
  185.       rect = item_rect(index)
  186.       rect.width -= 4
  187.       draw_item_name(item, rect.x, rect.y, enable?(index), rect.width)
  188.     end
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 绘制名称
  192.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  193.   #--------------------------------------------------------------------------
  194.   def draw_item_name(item, x, y, enabled = true, width = 230)
  195.     return unless item
  196.     text = item.name
  197.     change_color(normal_color, enabled)
  198.     draw_text(x, y, width, line_height, text)
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 更新帮助内容
  202.   #--------------------------------------------------------------------------
  203.   def update_help
  204.     @help_window.set_item(item)
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 刷新
  208.   #--------------------------------------------------------------------------
  209.   def refresh
  210.     make_item_list
  211.     create_contents
  212.     draw_all_items
  213.   end
  214. end
  215. #==============================================================================
  216. # ■ Window_SkillStatus
  217. #------------------------------------------------------------------------------
  218. #  技能画面中,显示技能使用者状态的窗口。
  219. #==============================================================================

  220. class Window_SkillStatus < Window_Base

  221. end

  222. #==============================================================================
  223. # ■ Window_NicknameStatus
  224. #------------------------------------------------------------------------------
  225. #  技能画面中,显示技能使用者状态的窗口。
  226. #==============================================================================

  227. class Window_NicknameStatus < Window_Base
  228.   #--------------------------------------------------------------------------
  229.   # ● 初始化对象 overwrite
  230.   #--------------------------------------------------------------------------
  231.   def initialize(x, y)
  232.     super(x, y, window_width, fitting_height(4))
  233.     @actor = nil
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 获取窗口的宽度
  237.   #--------------------------------------------------------------------------
  238.   def window_width
  239.     Graphics.width
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 设置角色
  243.   #--------------------------------------------------------------------------
  244.   def actor=(actor)
  245.     return if @actor == actor
  246.     @actor = actor
  247.     refresh
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 刷新
  251.   #--------------------------------------------------------------------------
  252.   def refresh
  253.     contents.clear
  254.     return unless @actor
  255.     draw_actor_face(@actor, 0, 0)
  256.     draw_actor_simple_status(@actor, 108, line_height / 2)
  257.   end
  258.     #--------------------------------------------------------------------------
  259.   # ● 绘制简单的状态
  260.   #--------------------------------------------------------------------------
  261.   def draw_actor_simple_status(actor, x, y)
  262.     draw_actor_name(actor, x, y)
  263.     draw_actor_level(actor, x, y + line_height * 1)
  264.     draw_actor_icons(actor, x, y + line_height * 2)
  265.     draw_actor_class(actor, x + 140, y, 280)
  266.     draw_actor_nickname(actor, x + 140, y + line_height * 1, 280)
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 绘制职业
  270.   #--------------------------------------------------------------------------
  271.   def draw_actor_class(actor, x, y, width = 180)
  272.     change_color(normal_color)
  273.     draw_text(x, y, width, line_height, "职业:" + actor.class.name)
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 绘制称号
  277.   #--------------------------------------------------------------------------
  278.   def draw_actor_nickname(actor, x, y, width = 180)
  279.     change_color(normal_color)
  280.     draw_text(x, y, width, line_height, "称号:" + actor.nickname)
  281.   end
  282. end
复制代码

点评

想问问“默认称号”能不能因人而异?  发表于 2013-2-16 22:24
非常感谢!效果很好。  发表于 2012-5-30 17:46

评分

参与人数 2星屑 +732 梦石 +2 收起 理由
迷糊的安安 + 600 + 2 认可答案 附赠66RPG提供的精美好人卡一张^^.
Luciffer + 132 前辈大触

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-15 23:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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