Project1

标题: 关于菜单里人物装备的问题 [打印本页]

作者: 牧羊仔    时间: 2015-6-2 17:17
标题: 关于菜单里人物装备的问题
本帖最后由 牧羊仔 于 2015-6-2 17:19 编辑

人物更换装备的属性提示只有攻击力、物防和魔防,我法师的装备需要看魔力怎么办,需要怎么修改脚本?


顺便求个菜单脚本。。
作者: cinderelmini    时间: 2015-6-2 17:29
本帖最后由 cinderelmini 于 2015-6-2 17:31 编辑

Window_EquipLeft里面的refresh里,
前面有3个draw_actor_parameter,
参考Window_Base里的方法内,可以自己加一个draw_actor_parameter(@actor, 4, 160, 6)
括弧传送的最后一个参数是类型,6就是魔力。
当然,这样做的话还需要把窗口的高度调高32像素,不然看不见,
之后在def set_new_parameters(new_atk, new_pdef, new_mdef)这里,
括弧里需要传多一个参数,可以加在最后,new_int
然后照着里面几个新值的赋值,把新的魔力值代进去。
之后refresh里面照猫画虎加一个新值的描绘~

之后就是在Scene_Equip里面找set_new_parameters的应用,
在里面加上魔力传过去就好~
(原版为例:Scene_Equip 97行:
  1. @left_window.set_new_parameters(nil, nil, nil, nil)
复制代码
99~117行:

  1.     # 物品窗口被激活的情况下
  2.     if @item_window.active
  3.       # 获取现在选中的物品
  4.       item2 = @item_window.item
  5.       # 变更装备
  6.       last_hp = @actor.hp
  7.       last_sp = @actor.sp
  8.       @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
  9.       # 获取变更装备后的能力值
  10.       new_atk = @actor.atk
  11.       new_pdef = @actor.pdef
  12.       new_mdef = @actor.mdef
  13.       new_int = @actor.int
  14.       # 返回到装备
  15.       @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
  16.       @actor.hp = last_hp
  17.       @actor.sp = last_sp
  18.       # 描画左窗口
  19.       @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_int)
  20.     end
复制代码
大概就是这么干~)

作者: 汪汪    时间: 2015-6-2 18:07
我觉得用这个装备脚本 比较好
  1. #==============================================================================
  2. # ■ Window_Base
  3. #BY:亿万星辰
  4. #------------------------------------------------------------------------------
  5. #  游戏中全部窗口的超级类。
  6. #==============================================================================

  7. class Window_Base < Window
  8.   def up_color
  9.     return Color.new(255, 0, 0)
  10.   end
  11.   def down_color
  12.     return Color.new(0, 255, 0)
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 描绘能力值
  16.   #     actor : 角色
  17.   #     x     : 描画目标 X 坐标
  18.   #     y     : 描画目标 Y 坐标
  19.   #     type  : 能力值种类 (0~6)
  20.   #--------------------------------------------------------------------------
  21.   def draw_actor_parameter(actor, x, y, type)
  22.     case type
  23.     when 0
  24.       parameter_name = $data_system.words.atk
  25.       parameter_value = actor.atk
  26.     when 1
  27.       parameter_name = $data_system.words.pdef
  28.       parameter_value = actor.pdef
  29.     when 2
  30.       parameter_name = $data_system.words.mdef
  31.       parameter_value = actor.mdef
  32.     when 3
  33.       parameter_name = $data_system.words.str
  34.       parameter_value = actor.str
  35.     when 4
  36.       parameter_name = $data_system.words.dex
  37.       parameter_value = actor.dex
  38.     when 5
  39.       parameter_name = $data_system.words.agi
  40.       parameter_value = actor.agi
  41.     when 6
  42.       parameter_name = $data_system.words.int
  43.       parameter_value = actor.int
  44.     ###############################################################
  45.     when 7
  46.       parameter_name = "回避"
  47.       parameter_value = actor.eva
  48.     end
  49.     self.contents.font.color = system_color
  50.     self.contents.draw_text(x, y, 120, 32, parameter_name)
  51.     self.contents.font.color = normal_color
  52.     self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  53.   end
  54. end

  55. #==============================================================================
  56. # ■ Window_EquipLeft
  57. #------------------------------------------------------------------------------
  58. #  装备画面的、显示角色能力值变化的窗口。
  59. #==============================================================================

  60. class Window_EquipLeft < Window_Base
  61.   #--------------------------------------------------------------------------
  62.   # ● 初始化对像
  63.   #     actor : 角色
  64.   #--------------------------------------------------------------------------
  65.   def initialize(actor)
  66.     super(0, 64, 272, 416)
  67.     self.contents = Bitmap.new(width - 32, height - 32)
  68.     @actor = actor
  69.     refresh
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 刷新
  73.   #--------------------------------------------------------------------------
  74.   def refresh
  75.     self.contents.clear
  76.     draw_actor_name(@actor, 4, 0)
  77.     draw_actor_level(@actor, 4, 32)
  78.     ###############################################################
  79.     draw_actor_parameter(@actor, 4, 64, 0)
  80.     draw_actor_parameter(@actor, 4, 96, 1)
  81.     draw_actor_parameter(@actor, 4, 128, 2)
  82.     draw_actor_parameter(@actor, 4, 160, 7)
  83.     draw_actor_parameter(@actor, 4, 192, 3)
  84.     draw_actor_parameter(@actor, 4, 224, 4)
  85.     draw_actor_parameter(@actor, 4, 256, 5)
  86.     draw_actor_parameter(@actor, 4, 288, 6)
  87.     if @new_atk != nil
  88.       self.contents.font.color = system_color
  89.       self.contents.draw_text(160, 64, 40, 32, "→", 1)
  90.       self.contents.font.color = @new_atk>@actor.atk ? up_color : down_color
  91.       self.contents.font.color = normal_color if @new_atk == @actor.atk
  92.       self.contents.draw_text(200, 64, 36, 32, @new_atk.to_s, 2)
  93.     end
  94.     if @new_pdef != nil
  95.       self.contents.font.color = system_color
  96.       self.contents.draw_text(160, 96, 40, 32, "→", 1)
  97.       self.contents.font.color = @new_pdef>@actor.pdef ? up_color : down_color
  98.       self.contents.font.color = normal_color if @new_pdef == @actor.pdef
  99.       self.contents.draw_text(200, 96, 36, 32, @new_pdef.to_s, 2)
  100.     end
  101.     if @new_mdef != nil
  102.       self.contents.font.color = system_color
  103.       self.contents.draw_text(160, 128, 40, 32, "→", 1)
  104.       self.contents.font.color = @new_mdef>@actor.mdef ? up_color : down_color
  105.       self.contents.font.color = normal_color if @new_mdef == @actor.mdef
  106.       self.contents.draw_text(200, 128, 36, 32, @new_mdef.to_s, 2)
  107.     end
  108.     if @new_eva != nil
  109.       self.contents.font.color = system_color
  110.       self.contents.draw_text(160, 160, 40, 32, "→", 1)
  111.       self.contents.font.color = @new_eva>@actor.eva ? up_color : down_color
  112.       self.contents.font.color = normal_color if @new_eva == @actor.eva
  113.       self.contents.draw_text(200, 160, 36, 32, @new_eva.to_s, 2)
  114.     end
  115.     if @new_str != nil
  116.       self.contents.font.color = system_color
  117.       self.contents.draw_text(160, 192, 40, 32, "→", 1)
  118.       self.contents.font.color = @new_str>@actor.str ? up_color : down_color
  119.       self.contents.font.color = normal_color if @new_str == @actor.str
  120.       self.contents.draw_text(200, 192, 36, 32, @new_str.to_s, 2)
  121.     end
  122.     if @new_dex != nil
  123.       self.contents.font.color = system_color
  124.       self.contents.draw_text(160, 224, 40, 32, "→", 1)
  125.       self.contents.font.color = @new_dex>@actor.dex ? up_color : down_color
  126.       self.contents.font.color = normal_color if @new_dex == @actor.dex
  127.       self.contents.draw_text(200, 224, 36, 32, @new_dex.to_s, 2)
  128.     end
  129.     if @new_agi != nil
  130.       self.contents.font.color = system_color
  131.       self.contents.draw_text(160, 256, 40, 32, "→", 1)
  132.       self.contents.font.color = @new_agi>@actor.agi ? up_color : down_color
  133.       self.contents.font.color = normal_color if @new_agi == @actor.agi
  134.       self.contents.draw_text(200, 256, 36, 32, @new_agi.to_s, 2)
  135.     end
  136.     if @new_int != nil
  137.       self.contents.font.color = system_color
  138.       self.contents.draw_text(160, 288, 40, 32, "→", 1)
  139.       self.contents.font.color = @new_int>@actor.int ? up_color : down_color
  140.       self.contents.font.color = normal_color if @new_int == @actor.int
  141.       self.contents.draw_text(200, 288, 36, 32, @new_int.to_s, 2)
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 变更装备后的能力值设置
  146.   #     new_atk  : 变更装备后的攻击力
  147.   #     new_pdef : 变更装备后的物理防御
  148.   #     new_mdef : 变更装备后的魔法防御
  149.   #--------------------------------------------------------------------------
  150.     ###############################################################
  151.   def set_new_parameters(new_atk, new_pdef, new_mdef, new_eva, new_str, new_dex, new_agi, new_int)
  152.     if @new_atk != new_atk or @new_pdef !=new_pdef or @new_mdef != new_mdef or @new_eva != new_eva or @new_str != new_str or @new_dex !=new_dex or @new_agi != new_agi or @new_int != new_int
  153.       @new_atk = new_atk
  154.       @new_pdef = new_pdef
  155.       @new_mdef = new_mdef
  156.       @new_eva = new_eva
  157.       @new_str = new_str
  158.       @new_dex = new_dex
  159.       @new_agi = new_agi
  160.       @new_int = new_int
  161.       refresh
  162.     end
  163.   end
  164. end

  165. #==============================================================================
  166. # ■ Window_EquipItem
  167. #------------------------------------------------------------------------------
  168. #  装备画面、显示浏览变更装备的候补物品的窗口。
  169. #==============================================================================

  170. class Window_EquipItem < Window_Selectable
  171.   #--------------------------------------------------------------------------
  172.   # ● 初始化对像
  173.   #     actor      : 角色
  174.   #     equip_type : 装备部位 (0~3)
  175.   #--------------------------------------------------------------------------
  176.   def initialize(actor, equip_type)
  177.     ################改了改坐标和高度#################################
  178.     super(272, 256, 368, 224)
  179.     @actor = actor
  180.     @equip_type = equip_type
  181.     @column_max = 1
  182.     refresh
  183.     self.active = false
  184.     self.index = -1
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ● 项目的描绘
  188.   #     index : 项目符号
  189.   #--------------------------------------------------------------------------
  190.   def draw_item(index)
  191.     item = @data[index]
  192.     ################改了改坐标#################################
  193.     x = 4
  194.     y = index * 32
  195.     case item
  196.     when RPG::Weapon
  197.       number = $game_party.weapon_number(item.id)
  198.     when RPG::Armor
  199.       number = $game_party.armor_number(item.id)
  200.     end
  201.     bitmap = RPG::Cache.icon(item.icon_name)
  202.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  203.     self.contents.font.color = normal_color
  204.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  205.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  206.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  207.   end
  208. end

  209. #==============================================================================
  210. # ■ Scene_Equip
  211. #------------------------------------------------------------------------------
  212. #  处理装备画面的类。
  213. #==============================================================================

  214. class Scene_Equip
  215.   #--------------------------------------------------------------------------
  216.   # ● 刷新
  217.   #--------------------------------------------------------------------------
  218.   def refresh
  219.     # 设置物品窗口的可视状态
  220.     @item_window1.visible = (@right_window.index == 0)
  221.     @item_window2.visible = (@right_window.index == 1)
  222.     @item_window3.visible = (@right_window.index == 2)
  223.     @item_window4.visible = (@right_window.index == 3)
  224.     @item_window5.visible = (@right_window.index == 4)
  225.     # 获取当前装备中的物品
  226.     item1 = @right_window.item
  227.     # 设置当前的物品窗口到 @item_window
  228.     case @right_window.index
  229.     when 0
  230.       @item_window = @item_window1
  231.     when 1
  232.       @item_window = @item_window2
  233.     when 2
  234.       @item_window = @item_window3
  235.     when 3
  236.       @item_window = @item_window4
  237.     when 4
  238.       @item_window = @item_window5
  239.     end
  240.     # 右窗口被激活的情况下
  241.     if @right_window.active
  242.       # 删除变更装备后的能力
  243.     ###############################################################
  244.       @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
  245.     end
  246.     # 物品窗口被激活的情况下
  247.     if @item_window.active
  248.       # 获取现在选中的物品
  249.       item2 = @item_window.item
  250.       # 变更装备
  251.       last_hp = @actor.hp
  252.       last_sp = @actor.sp
  253.       @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
  254.       # 获取变更装备后的能力值
  255.     ###############################################################
  256.       new_atk = @actor.atk
  257.       new_pdef = @actor.pdef
  258.       new_mdef = @actor.mdef
  259.       new_eva = @actor.eva
  260.       new_str = @actor.str
  261.       new_dex = @actor.dex
  262.       new_agi = @actor.agi
  263.       new_int = @actor.int
  264.       # 返回到装备
  265.       @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
  266.       @actor.hp = last_hp
  267.       @actor.sp = last_sp
  268.       # 描画左窗口
  269.     ###############################################################
  270.       @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_eva, new_str, new_dex, new_agi, new_int)
  271.     end
  272.   end
  273. end
复制代码

作者: 牧羊仔    时间: 2015-6-3 09:59
汪汪 发表于 2015-6-2 18:07
我觉得用这个装备脚本 比较好

谢谢!!!!!!!!!!!




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1