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

Project1

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

[已经过期] 谁帮忙改下,物品快捷键脚本

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
110
在线时间
85 小时
注册时间
2010-8-19
帖子
137
跳转到指定楼层
1
发表于 2011-1-6 12:54:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
[img]#==============================================================================
# ■ Window_Item_KeyCommand
#------------------------------------------------------------------------------
#  选择快捷键的窗口
#==============================================================================
class Window_Item_KeyCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(160-16, 480-78, 346, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    @item_max = 3
    @column_max = 3
    @commands = ["Z", "X", "C"]
    refresh
    self.index = -1
    self.active = false
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh(actor=nil)
    self.contents.clear
    if actor != nil
      u = 0
      for key in ["Z","X","C"]
        item = $data_items[actor.item_key[key]]
        if !item.nil?
          if $game_party.item_number(item.id) == 0
            actor.item_key[key] = 0
            refresh(actor)
            return
          end
          bitmap = RPG::Cache.icon(item.icon_name)
          x = 65 + u * (120)/3
          self.contents.font.size = 12
          self.contents.font.color = Color.new(255,255,255,255)
          self.contents.blt(x,16,bitmap,Rect.new(0,0,30,30))
          self.contents.draw_text(x,26, 128, 32,"x")
          self.contents.draw_text(x+10,24, 128, 40,"#{$game_party.item_number(item.id)}")
        end
          u += 1
      end
    end
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 70 + index * (120)/3
    self.contents.font.size = 16
    self.contents.font.color = Color.new(20,20,20)
    self.contents.draw_text(x+1, 1, 128, 32, @commands[index])
    self.contents.font.color = Color.new(135,175,255)
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  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
    # 计算光标坐标
    x = @index % @column_max * (120)/3
    y = @index / @column_max * 32 - self.oy
    # 更新国标矩形
    self.cursor_rect.set(48+x, y+8, 40, 40)
  end
end
#==============================================================================
# ■ Scene_Key
#------------------------------------------------------------------------------
#  处理中快捷键的类。
#==============================================================================

class Scene_Item_Key < Scene_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor_index : 角色索引
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0)
    @actor_index = actor_index
    super()
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main_start
    super
    # 获取角色
    @actor = $game_party.actors[@actor_index]
    # 生成帮助窗口、状态窗口、特技窗口
    @help_window = Window_Help.new
    @item_window = Window_Item.new#(@actor)
    @item_window.z -= 98
    @item_window.height = 256
    @item_window.back_opacity = 160
    @help_window.back_opacity = 160
    @key_window = Window_Item_KeyCommand.new
    @key_window.refresh(@actor)
    # 关联帮助窗口
    @item_window.help_window = @help_window
   
   
    @windows.push(@help_window)
    @windows.push(@item_window)
    @windows.push(@key_window)
  end
  def make_sprite
    @spriteset = Spriteset_Map.new
    @arpg_actor = ARPG_Actor.new
  end
  def dispose_sprite
    @spriteset.dispose
    @arpg_actor.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新命令窗口
    @arpg_actor.update
    if @item_window.active
      update_item
      return
    end
    if @key_window.active
      update_key
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新技能窗口
  #--------------------------------------------------------------------------
  def update_item
    @item_window.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换到菜单画面
      $scene = Scene_Map.new
      return
    end
    # 按下 C 键的场合下
    if Input.trigger?(Input::C)
      item = @item_window.item
      return if !$game_party.item_can_use?(item.id)
      M.ok
      @item_window.active = false
      @key_window.active = true
      @key_window.index = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新选择键位
  #--------------------------------------------------------------------------
  def update_key
    @key_window.update
    if Input.trigger?(Input::C)
      item = @item_window.item
      case @key_window.index
      when 0
        key_start("Z",item)
      when 1
        key_start("X",item)
      when 2
        key_start("C",item)
      end
    end
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      @item_window.active = true
      @key_window.active = false
      @key_window.index = -1
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置键位
  #--------------------------------------------------------------------------
  def key_start(key,item)
    if item.nil?
      @actor.item_key[key] = 0
    else
      @actor.item_key[key] = item.id
    end
    @item_window.active = true
    @key_window.active = false
    @key_window.index = -1
    @key_window.refresh(@actor)
    M.eq
    return
  end
end
[/img]




帮我改成,只有恢复品才可以加入到快捷栏里

点评

除了恢复品,在物品栏里回车,都是直接执行事件  发表于 2011-1-6 12:57
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2025-7-21 00:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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