查看: 2997|回复: 7

[已经解决] 怎么做扔掉东西的功能

[复制链接]
梦石
0
星屑
75
在线时间
27 小时
注册时间
2014-7-19
回帖
87
发表于 2014-9-17 14:54:49 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 qmario 于 2014-10-7 13:20 编辑

如题……
@︶ㄣ牛排ぶ 哦哦

点评

手动认可有奖  发表于 2014-10-6 21:53

评分

参与人数 1星屑 +35 收起 理由
︶ㄣ牛排ぶ + 35 手动认可奖励

查看全部评分

梦石
0
星屑
75
在线时间
27 小时
注册时间
2014-7-19
回帖
87
 楼主| 发表于 2014-9-17 14:55:18 | 显示全部楼层
注意是在物品界面扔
回复

使用道具 举报

梦石
3
星屑
6420
在线时间
1131 小时
注册时间
2007-12-26
回帖
914
发表于 2014-9-17 15:25:16 | 显示全部楼层
本帖最后由 幻耶 于 2014-9-17 16:22 编辑

Scene_Item 脚本中添加一句 $used_item_id = @item.id  可以提取被使用物品的编号,然后对物品设置公共事件,失去编号为$used_item_id的物品。

  #--------------------------------------------------------------------------
  # ● 刷新画面 (物品窗口被激活的情况下)
  #--------------------------------------------------------------------------
  def update_item
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换到菜单画面
      $scene = Scene_Menu.new(0)
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 获取物品窗口当前选中的物品数据
      @item = @item_window.item
      $used_item_id = @item.id
囡囚囨囚囨図囨囧
回复

使用道具 举报

梦石
0
星屑
49
在线时间
200 小时
注册时间
2014-7-17
回帖
372
发表于 2014-9-17 21:08:58 | 显示全部楼层
幻耶 发表于 2014-9-17 15:25
Scene_Item 脚本中添加一句 $used_item_id = @item.id  可以提取被使用物品的编号,然后对物品设置公共事件 ...

帮层主补充一点:脚本里用$game_party.lose_item($used_item_id,1)

知其然,而不欲知其所以然,耻也!
回复

使用道具 举报

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2014-9-18 13:54:37 | 显示全部楼层
本帖最后由 RyanBern 于 2015-7-31 11:35 编辑

感觉LS的回答有点问题,如果真的那样去做了,那么点击一个物品之后,到底是使用还是丢弃就不确定了。
这个脚本重设了def update_item方法,在点击任何一件物品时(武器防具也可),会出现“使用”和“丢弃”的命令框,根据命令进行操作。
用法:粘贴到Main前,可能会和某些脚本冲突(例如更改物品界面结构的脚本)。另外这个丢弃功能只在平时有效,战斗的时候无效。
范例: Project10.rar (188.08 KB, 下载次数: 82)
[pre lang="Ruby"]class Window_ItemCommand < Window_Command
  attr_accessor :calling_window
  def initialize(width, commands)
    super(width, commands)
    @item = nil
    @calling_window = nil
    self.z = 120
    self.active = false
    self.visible = false
  end
  def item=(item)
    @item = item
    refresh
  end
  def refresh
    self.contents.clear
    (0...@item_max).each do |i|
      draw_item(i, normal_color)
    end
    unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
      disable_item(0)
    end
  end
  def adjust_position
    if @calling_window.nil?
      return
    end
    if @calling_window.cursor_y + 32 + self.height < 480
      self.y = @calling_window.cursor_y + 32
    else
      self.y = @calling_window.cursor_y - self.height
    end
    self.x = @calling_window.cursor_x
  end
end

class Window_Selectable
  def cursor_x
    cursor_width = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + 32) + self.x + 16
    return x
  end
  def cursor_y
    y = @index / @column_max * 32 - self.oy + self.y + 16
    return y
  end
end


class Window_Dump < Window_Base
  def initialize
    super(0, 0, 176, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.x = 320 - width / 2
    self.y = 240 - height / 2
    self.z = 200
    self.active = false
    self.visible = false
    @max = 1
    @number = 1
  end
  def set(max)
    @max = max
    @number = 1
    refresh
  end
  def number
    return @number
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
    self.contents.font.color = normal_color
    self.contents.draw_text(72, 32, 32, 32, "×")
    self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
    self.cursor_rect.set(100, 32, 32, 32)
  end
  def update
    super
    if self.active
      # 光标右 (+1)
      if Input.repeat?(Input::RIGHT) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number += 1
        refresh
      end
      # 光标左 (-1)
      if Input.repeat?(Input::LEFT) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number -= 1
        refresh
      end
      # 光标上 (+10)
      if Input.repeat?(Input::UP) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number = [@number + 10, @max].min
        refresh
      end
      # 光标下 (-10)
      if Input.repeat?(Input::DOWN) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number = [@number - 10, 1].max
        refresh
      end
    end
  end
end


class Scene_Item
  alias rb_main main
  def main
    @dump_window = Window_Dump.new
    @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
    rb_main
    @dump_window.dispose
    @command_window.dispose
  end
  def update
    @command_window.calling_window = @item_window
    @dump_window.update
    @command_window.update
    @help_window.update
    @item_window.update
    @target_window.update
    if @item_window.active
      update_item
      return
    end
    if @target_window.active
      update_target
      return
    end
    if @command_window.active
      update_command
      return
    end
    if @dump_window.active
      update_dump
      return
    end
  end
  def update_item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0)
      return
    end
    if Input.trigger?(Input::C)
      @item = @item_window.item
      if @item.nil?
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @command_window.item = @item
      @command_window.adjust_position
      @command_window.index = 0
      @command_window.active = true
      @command_window.visible = true
      @item_window.active = false
      return
    end
  end
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.visible = false
      @command_window.active = false
      @item_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        if @item.scope >= 3
          @command_window.active = false
          @command_window.visible = false
          @target_window.x = (@item_window.index + 1) % 2 * 304
          @target_window.visible = true
          @target_window.active = true
          if @item.scope == 4 || @item.scope == 6
            @target_window.index = -1
          else
            @target_window.index = 0
          end
        else
          if @item.common_event_id > 0
            $game_temp.common_event_id = @item.common_event_id
            $game_system.se_play(@item.menu_se)
            if @item.consumable
              $game_party.lose_item(@item.id, 1)
              @item_window.draw_item(@item_window.index)
            end
            $scene = Scene_Map.new
            return
          end
        end
      when 1
        case @item
        when RPG::Item
          number = $game_party.item_number(@item.id)
        when RPG::Weapon
          number = $game_party.weapon_number(@item.id)
        when RPG::Armor
          number = $game_party.weapon_number(@item.id)
        end
        $game_system.se_play($data_system.decision_se)
        @dump_window.set(number)
        @dump_window.visible = true
        @dump_window.active = true
        @command_window.visible = false
        @command_window.active = false
      end
    end
    return
  end
  def update_dump
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @dump_window.visible = false
      @dump_window.active = false
      @command_window.active = true
      @command_window.visible = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)
      number = @dump_window.number
      case @item
      when RPG::Item
        $game_party.lose_item(@item.id, number)
      when RPG::Weapon
        $game_party.lose_weapon(@item.id, number)
      when RPG::Armor
        $game_party.lose_armor(@item.id, number)
      end
      @dump_window.visible = false
      @dump_window.active = false
      @item_window.active = true
      @item_window.refresh
      return
    end
  end
end[/pre]   

点评

非常感谢!目前和其他脚本没有冲突。  发表于 2014-9-19 21:02

评分

参与人数 1梦石 +1 收起 理由
︶ㄣ牛排ぶ + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2014-9-19 22:15:47 | 显示全部楼层
你是要扔到地图上还是直接扔了?

点评

直接扔了,已解决  发表于 2014-9-23 21:29
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

梦石
0
星屑
50
在线时间
641 小时
注册时间
2015-7-29
回帖
188
发表于 2015-7-31 11:02:12 | 显示全部楼层
脚本第59行发生问题是什么情况- -   你能用吗  我我怎么提示59行发生问题

点评

大神一个。。。鉴定完毕  发表于 2015-7-31 11:17
改为'@max = 1',论坛旧BUG导致代码变异。  发表于 2015-7-31 11:06
回复

使用道具 举报

梦石
0
星屑
50
在线时间
641 小时
注册时间
2015-7-29
回帖
188
发表于 2015-7-31 11:20:52 | 显示全部楼层
黄谊洲 发表于 2015-7-31 11:02
脚本第59行发生问题是什么情况- -   你能用吗  我我怎么提示59行发生问题

大神,59行我改了,可以了 ,但是我是新建的工程,没有任何脚本擦件。改完又出现这样的错误是怎么回事?求指教

4

4

点评

对不起- - 我是瞎子,(一库)!! 我居然用 vxace 测试  发表于 2015-7-31 11:40
我在脚本的那个楼层附上范例,可以下载一下。回复我请在同层点评,不要再点回复了。(此帖是坟贴)  发表于 2015-7-31 11:34
我在新工程里面测试没有问题。请检查一下使用方法是否正确。1. 工具是否为RMXP?2. 脚本是否粘贴到了Main组前面的那个位置  发表于 2015-7-31 11:33
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部