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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
75
在线时间
27 小时
注册时间
2014-7-19
帖子
110
跳转到指定楼层
1
发表于 2014-9-17 14:54:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

点评

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

评分

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

查看全部评分

Lv1.梦旅人

梦石
0
星屑
75
在线时间
27 小时
注册时间
2014-7-19
帖子
110
2
 楼主| 发表于 2014-9-17 14:55:18 | 只看该作者
注意是在物品界面扔
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
3
星屑
6420
在线时间
1131 小时
注册时间
2007-12-26
帖子
2402
3
发表于 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
囡囚囨囚囨図囨囧
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
200 小时
注册时间
2014-7-17
帖子
410
4
发表于 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)

知其然,而不欲知其所以然,耻也!
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
9497
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

5
发表于 2014-9-18 13:54:37 | 只看该作者
本帖最后由 RyanBern 于 2015-7-31 11:35 编辑

感觉LS的回答有点问题,如果真的那样去做了,那么点击一个物品之后,到底是使用还是丢弃就不确定了。
这个脚本重设了def update_item方法,在点击任何一件物品时(武器防具也可),会出现“使用”和“丢弃”的命令框,根据命令进行操作。
用法:粘贴到Main前,可能会和某些脚本冲突(例如更改物品界面结构的脚本)。另外这个丢弃功能只在平时有效,战斗的时候无效。
范例: Project10.rar (188.08 KB, 下载次数: 82)
RUBY 代码复制
  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.  
  37. class Window_Selectable
  38.   def cursor_x
  39.     cursor_width = self.width / @column_max - 32
  40.     x = @index % @column_max * (cursor_width + 32) + self.x + 16
  41.     return x
  42.   end
  43.   def cursor_y
  44.     y = @index / @column_max * 32 - self.oy + self.y + 16
  45.     return y
  46.   end
  47. end
  48.  
  49.  
  50. class Window_Dump < Window_Base
  51.   def initialize
  52.     super(0, 0, 176, 96)
  53.     self.contents = Bitmap.new(width - 32, height - 32)
  54.     self.x = 320 - width / 2
  55.     self.y = 240 - height / 2
  56.     self.z = 200
  57.     self.active = false
  58.     self.visible = false
  59.     @max = 1
  60.     @number = 1
  61.   end
  62.   def set(max)
  63.     @max = max
  64.     @number = 1
  65.     refresh
  66.   end
  67.   def number
  68.     return @number
  69.   end
  70.   def refresh
  71.     self.contents.clear
  72.     self.contents.font.color = system_color
  73.     self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
  74.     self.contents.font.color = normal_color
  75.     self.contents.draw_text(72, 32, 32, 32, "×")
  76.     self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
  77.     self.cursor_rect.set(100, 32, 32, 32)
  78.   end
  79.   def update
  80.     super
  81.     if self.active
  82.       # 光标右 (+1)
  83.       if Input.repeat?(Input::RIGHT) and @number < @max
  84.         $game_system.se_play($data_system.cursor_se)
  85.         @number += 1
  86.         refresh
  87.       end
  88.       # 光标左 (-1)
  89.       if Input.repeat?(Input::LEFT) and @number > 1
  90.         $game_system.se_play($data_system.cursor_se)
  91.         @number -= 1
  92.         refresh
  93.       end
  94.       # 光标上 (+10)
  95.       if Input.repeat?(Input::UP) and @number < @max
  96.         $game_system.se_play($data_system.cursor_se)
  97.         @number = [@number + 10, @max].min
  98.         refresh
  99.       end
  100.       # 光标下 (-10)
  101.       if Input.repeat?(Input::DOWN) and @number > 1
  102.         $game_system.se_play($data_system.cursor_se)
  103.         @number = [@number - 10, 1].max
  104.         refresh
  105.       end
  106.     end
  107.   end
  108. end
  109.  
  110.  
  111. class Scene_Item
  112.   alias rb_main main
  113.   def main
  114.     @dump_window = Window_Dump.new
  115.     @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
  116.     rb_main
  117.     @dump_window.dispose
  118.     @command_window.dispose
  119.   end
  120.   def update
  121.     @command_window.calling_window = @item_window
  122.     @dump_window.update
  123.     @command_window.update
  124.     @help_window.update
  125.     @item_window.update
  126.     @target_window.update
  127.     if @item_window.active
  128.       update_item
  129.       return
  130.     end
  131.     if @target_window.active
  132.       update_target
  133.       return
  134.     end
  135.     if @command_window.active
  136.       update_command
  137.       return
  138.     end
  139.     if @dump_window.active
  140.       update_dump
  141.       return
  142.     end
  143.   end
  144.   def update_item
  145.     if Input.trigger?(Input::B)
  146.       $game_system.se_play($data_system.cancel_se)
  147.       $scene = Scene_Menu.new(0)
  148.       return
  149.     end
  150.     if Input.trigger?(Input::C)
  151.       @item = @item_window.item
  152.       if @item.nil?
  153.         $game_system.se_play($data_system.buzzer_se)
  154.         return
  155.       end
  156.       $game_system.se_play($data_system.decision_se)
  157.       @command_window.item = @item
  158.       @command_window.adjust_position
  159.       @command_window.index = 0
  160.       @command_window.active = true
  161.       @command_window.visible = true
  162.       @item_window.active = false
  163.       return
  164.     end
  165.   end
  166.   def update_command
  167.     if Input.trigger?(Input::B)
  168.       $game_system.se_play($data_system.cancel_se)
  169.       @command_window.visible = false
  170.       @command_window.active = false
  171.       @item_window.active = true
  172.       return
  173.     end
  174.     if Input.trigger?(Input::C)
  175.       case @command_window.index
  176.       when 0
  177.         unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  178.           $game_system.se_play($data_system.buzzer_se)
  179.           return
  180.         end
  181.         $game_system.se_play($data_system.decision_se)
  182.         if @item.scope >= 3
  183.           @command_window.active = false
  184.           @command_window.visible = false
  185.           @target_window.x = (@item_window.index + 1) % 2 * 304
  186.           @target_window.visible = true
  187.           @target_window.active = true
  188.           if @item.scope == 4 || @item.scope == 6
  189.             @target_window.index = -1
  190.           else
  191.             @target_window.index = 0
  192.           end
  193.         else
  194.           if @item.common_event_id > 0
  195.             $game_temp.common_event_id = @item.common_event_id
  196.             $game_system.se_play(@item.menu_se)
  197.             if @item.consumable
  198.               $game_party.lose_item(@item.id, 1)
  199.               @item_window.draw_item(@item_window.index)
  200.             end
  201.             $scene = Scene_Map.new
  202.             return
  203.           end
  204.         end
  205.       when 1
  206.         case @item
  207.         when RPG::Item
  208.           number = $game_party.item_number(@item.id)
  209.         when RPG::Weapon
  210.           number = $game_party.weapon_number(@item.id)
  211.         when RPG::Armor
  212.           number = $game_party.weapon_number(@item.id)
  213.         end
  214.         $game_system.se_play($data_system.decision_se)
  215.         @dump_window.set(number)
  216.         @dump_window.visible = true
  217.         @dump_window.active = true
  218.         @command_window.visible = false
  219.         @command_window.active = false
  220.       end
  221.     end
  222.     return
  223.   end
  224.   def update_dump
  225.     if Input.trigger?(Input::B)
  226.       $game_system.se_play($data_system.cancel_se)
  227.       @dump_window.visible = false
  228.       @dump_window.active = false
  229.       @command_window.active = true
  230.       @command_window.visible = true
  231.       return
  232.     end
  233.     if Input.trigger?(Input::C)
  234.       $game_system.se_play($data_system.shop_se)
  235.       number = @dump_window.number
  236.       case @item
  237.       when RPG::Item
  238.         $game_party.lose_item(@item.id, number)
  239.       when RPG::Weapon
  240.         $game_party.lose_weapon(@item.id, number)
  241.       when RPG::Armor
  242.         $game_party.lose_armor(@item.id, number)
  243.       end
  244.       @dump_window.visible = false
  245.       @dump_window.active = false
  246.       @item_window.active = true
  247.       @item_window.refresh
  248.       return
  249.     end
  250.   end
  251. end
   

点评

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

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9275
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

6
发表于 2014-9-19 22:15:47 | 只看该作者
你是要扔到地图上还是直接扔了?

点评

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
641 小时
注册时间
2015-7-29
帖子
211
7
发表于 2015-7-31 11:02:12 | 只看该作者
脚本第59行发生问题是什么情况- -   你能用吗  我我怎么提示59行发生问题

点评

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
641 小时
注册时间
2015-7-29
帖子
211
8
发表于 2015-7-31 11:20:52 | 只看该作者
黄谊洲 发表于 2015-7-31 11:02
脚本第59行发生问题是什么情况- -   你能用吗  我我怎么提示59行发生问题

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

QQ截图20150731111912.png (4.25 KB, 下载次数: 1)

4

4

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-3 07:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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