查看: 3088|回复: 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)
  1. class Window_ItemCommand < Window_Command
  2.   attr_accessor :calling_window
  3.   def initialize(width, commands)
  4.     super(width, commands)
  5.     @item = nil
  6.     @calling_window = nil
  7.     self.z = 120
  8.     self.active = false
  9.     self.visible = false
  10.   end
  11.   def item=(item)
  12.     @item = item
  13.     refresh
  14.   end
  15.   def refresh
  16.     self.contents.clear
  17.     (0...@item_max).each do |i|
  18.       draw_item(i, normal_color)
  19.     end
  20.     unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  21.       disable_item(0)
  22.     end
  23.   end
  24.   def adjust_position
  25.     if @calling_window.nil?
  26.       return
  27.     end
  28.     if @calling_window.cursor_y + 32 + self.height < 480
  29.       self.y = @calling_window.cursor_y + 32
  30.     else
  31.       self.y = @calling_window.cursor_y - self.height
  32.     end
  33.     self.x = @calling_window.cursor_x
  34.   end
  35. end

  36. class Window_Selectable
  37.   def cursor_x
  38.     cursor_width = self.width / @column_max - 32
  39.     x = @index % @column_max * (cursor_width + 32) + self.x + 16
  40.     return x
  41.   end
  42.   def cursor_y
  43.     y = @index / @column_max * 32 - self.oy + self.y + 16
  44.     return y
  45.   end
  46. end


  47. class Window_Dump < Window_Base
  48.   def initialize
  49.     super(0, 0, 176, 96)
  50.     self.contents = Bitmap.new(width - 32, height - 32)
  51.     self.x = 320 - width / 2
  52.     self.y = 240 - height / 2
  53.     self.z = 200
  54.     self.active = false
  55.     self.visible = false
  56.     @max = 1
  57.     @number = 1
  58.   end
  59.   def set(max)
  60.     @max = max
  61.     @number = 1
  62.     refresh
  63.   end
  64.   def number
  65.     return @number
  66.   end
  67.   def refresh
  68.     self.contents.clear
  69.     self.contents.font.color = system_color
  70.     self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
  71.     self.contents.font.color = normal_color
  72.     self.contents.draw_text(72, 32, 32, 32, "×")
  73.     self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
  74.     self.cursor_rect.set(100, 32, 32, 32)
  75.   end
  76.   def update
  77.     super
  78.     if self.active
  79.       # 光标右 (+1)
  80.       if Input.repeat?(Input::RIGHT) and @number < @max
  81.         $game_system.se_play($data_system.cursor_se)
  82.         @number += 1
  83.         refresh
  84.       end
  85.       # 光标左 (-1)
  86.       if Input.repeat?(Input::LEFT) and @number > 1
  87.         $game_system.se_play($data_system.cursor_se)
  88.         @number -= 1
  89.         refresh
  90.       end
  91.       # 光标上 (+10)
  92.       if Input.repeat?(Input::UP) and @number < @max
  93.         $game_system.se_play($data_system.cursor_se)
  94.         @number = [@number + 10, @max].min
  95.         refresh
  96.       end
  97.       # 光标下 (-10)
  98.       if Input.repeat?(Input::DOWN) and @number > 1
  99.         $game_system.se_play($data_system.cursor_se)
  100.         @number = [@number - 10, 1].max
  101.         refresh
  102.       end
  103.     end
  104.   end
  105. end


  106. class Scene_Item
  107.   alias rb_main main
  108.   def main
  109.     @dump_window = Window_Dump.new
  110.     @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
  111.     rb_main
  112.     @dump_window.dispose
  113.     @command_window.dispose
  114.   end
  115.   def update
  116.     @command_window.calling_window = @item_window
  117.     @dump_window.update
  118.     @command_window.update
  119.     @help_window.update
  120.     @item_window.update
  121.     @target_window.update
  122.     if @item_window.active
  123.       update_item
  124.       return
  125.     end
  126.     if @target_window.active
  127.       update_target
  128.       return
  129.     end
  130.     if @command_window.active
  131.       update_command
  132.       return
  133.     end
  134.     if @dump_window.active
  135.       update_dump
  136.       return
  137.     end
  138.   end
  139.   def update_item
  140.     if Input.trigger?(Input::B)
  141.       $game_system.se_play($data_system.cancel_se)
  142.       $scene = Scene_Menu.new(0)
  143.       return
  144.     end
  145.     if Input.trigger?(Input::C)
  146.       @item = @item_window.item
  147.       if @item.nil?
  148.         $game_system.se_play($data_system.buzzer_se)
  149.         return
  150.       end
  151.       $game_system.se_play($data_system.decision_se)
  152.       @command_window.item = @item
  153.       @command_window.adjust_position
  154.       @command_window.index = 0
  155.       @command_window.active = true
  156.       @command_window.visible = true
  157.       @item_window.active = false
  158.       return
  159.     end
  160.   end
  161.   def update_command
  162.     if Input.trigger?(Input::B)
  163.       $game_system.se_play($data_system.cancel_se)
  164.       @command_window.visible = false
  165.       @command_window.active = false
  166.       @item_window.active = true
  167.       return
  168.     end
  169.     if Input.trigger?(Input::C)
  170.       case @command_window.index
  171.       when 0
  172.         unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  173.           $game_system.se_play($data_system.buzzer_se)
  174.           return
  175.         end
  176.         $game_system.se_play($data_system.decision_se)
  177.         if @item.scope >= 3
  178.           @command_window.active = false
  179.           @command_window.visible = false
  180.           @target_window.x = (@item_window.index + 1) % 2 * 304
  181.           @target_window.visible = true
  182.           @target_window.active = true
  183.           if @item.scope == 4 || @item.scope == 6
  184.             @target_window.index = -1
  185.           else
  186.             @target_window.index = 0
  187.           end
  188.         else
  189.           if @item.common_event_id > 0
  190.             $game_temp.common_event_id = @item.common_event_id
  191.             $game_system.se_play(@item.menu_se)
  192.             if @item.consumable
  193.               $game_party.lose_item(@item.id, 1)
  194.               @item_window.draw_item(@item_window.index)
  195.             end
  196.             $scene = Scene_Map.new
  197.             return
  198.           end
  199.         end
  200.       when 1
  201.         case @item
  202.         when RPG::Item
  203.           number = $game_party.item_number(@item.id)
  204.         when RPG::Weapon
  205.           number = $game_party.weapon_number(@item.id)
  206.         when RPG::Armor
  207.           number = $game_party.weapon_number(@item.id)
  208.         end
  209.         $game_system.se_play($data_system.decision_se)
  210.         @dump_window.set(number)
  211.         @dump_window.visible = true
  212.         @dump_window.active = true
  213.         @command_window.visible = false
  214.         @command_window.active = false
  215.       end
  216.     end
  217.     return
  218.   end
  219.   def update_dump
  220.     if Input.trigger?(Input::B)
  221.       $game_system.se_play($data_system.cancel_se)
  222.       @dump_window.visible = false
  223.       @dump_window.active = false
  224.       @command_window.active = true
  225.       @command_window.visible = true
  226.       return
  227.     end
  228.     if Input.trigger?(Input::C)
  229.       $game_system.se_play($data_system.shop_se)
  230.       number = @dump_window.number
  231.       case @item
  232.       when RPG::Item
  233.         $game_party.lose_item(@item.id, number)
  234.       when RPG::Weapon
  235.         $game_party.lose_weapon(@item.id, number)
  236.       when RPG::Armor
  237.         $game_party.lose_armor(@item.id, number)
  238.       end
  239.       @dump_window.visible = false
  240.       @dump_window.active = false
  241.       @item_window.active = true
  242.       @item_window.refresh
  243.       return
  244.     end
  245.   end
  246. end
复制代码
  

点评

非常感谢!目前和其他脚本没有冲突。  发表于 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.

在本版发帖返回顶部