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

Project1

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

[已经解决] 【3VIP】背包系统求改~

[复制链接]

Lv1.梦旅人

梦石
0
星屑
149
在线时间
664 小时
注册时间
2011-9-25
帖子
241
跳转到指定楼层
1
发表于 2012-11-6 23:05:35 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
3星屑
  1. #==============================================================================
  2. # ■ 背包系统 —— by 水镜风生
  3. #------------------------------------------------------------------------------
  4. LOSE_ITEM_SE_NAME = "Evasion"         # 丢弃物品时播放的SE
  5. LOW_SPEED = 2                         # 背包塞满时的移动速度
  6. USUAL_SPEED = 4                       # 平时的移动速度
  7. WARING_STRING = "背包放的东西太多了。"  # 超重时的提示
  8. IM = 1                                # IM号系统变量决定物品种类的最大值
  9. #==============================================================================
  10. # ■ Scene_Item
  11. #------------------------------------------------------------------------------
  12. #  处理物品画面的类。
  13. #==============================================================================
  14. class Scene_Item < Scene_Base
  15.   #--------------------------------------------------------------------------
  16.   # ● 开始处理
  17.   #--------------------------------------------------------------------------
  18.   def start
  19.     super
  20.     create_menu_background
  21.     @viewport = Viewport.new(0, 0, 544, 416)
  22.     @help_window = Window_Help.new
  23.     @help_window.viewport = @viewport
  24.     @item_window = Window_Item.new(0, 67, 544, 280)
  25.     @item_window.viewport = @viewport
  26.     @item_window.help_window = @help_window
  27.     @item_window.active = false
  28.     @target_window = Window_MenuStatus.new(0, 0)
  29.     @max_window = Window_Item_Max.new
  30.     @max_window.viewport = @viewport
  31.     @number_window = Window_LoseNumber.new(142, 156)
  32.     @number_window.viewport = @viewport
  33.     @command_window = Window_Command.new(145, ["   使用","   丢弃"], 1, 2)
  34.     @command_window.x = 200
  35.     @command_window.y = 160
  36.     hide_command_window
  37.     hide_number_window
  38.     hide_target_window
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 结束处理
  42.   #--------------------------------------------------------------------------
  43.   alias terminate2 terminate
  44.   def terminate
  45.     terminate2
  46.     @max_window.dispose
  47.     @command_window.dispose
  48.     @number_window.dispose
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 回到原画面
  52.   #--------------------------------------------------------------------------
  53.   def return_scene
  54.     $scene = Scene_Menu.new(0)
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 更新画面
  58.   #--------------------------------------------------------------------------
  59.   def update
  60.     super
  61.     update_menu_background
  62.     @help_window.update
  63.     @item_window.update
  64.     @target_window.update
  65.     @max_window.update
  66.     @command_window.update
  67.     @number_window.update
  68.     if @item_window.active
  69.       update_item_selection
  70.     elsif @target_window.active
  71.       update_target_selection
  72.     elsif @command_window.active
  73.       update_command_selection
  74.     elsif @number_window.active
  75.       update_number_selection
  76.     end
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 更新物品选择
  80.   #--------------------------------------------------------------------------
  81.   def update_item_selection
  82.     if Input.trigger?(Input::B)
  83.       if  $game_party.items.size <= $game_variables[IM]# 如果物品种类没超过限制
  84.         $game_player.change_move_speed(USUAL_SPEED)
  85.       end
  86.         Sound.play_cancel
  87.         return_scene
  88.     elsif Input.trigger?(Input::C)
  89.       @item = @item_window.item
  90.       if @item != nil
  91.         $game_party.last_item_id = @item.id
  92.         Sound.play_decision
  93.           if $game_party.item_can_use?(@item)     # 物品是否可用
  94.             @command_window.draw_item(0,true)      
  95.           else  @command_window.draw_item(0,false) # 不可用的话【使用】选项颜色无效
  96.           end
  97.           if @item.price == 0                     # 物品价格是否为0   
  98.              @command_window.draw_item(1,false)    # 是的话【丢弃】选项无效
  99.           else  
  100.              @command_window.draw_item(1,true)
  101.           end
  102.              show_command_window
  103.        else
  104.          Sound.play_buzzer
  105.        end
  106.     end
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 更新目标选择
  110.   #--------------------------------------------------------------------------
  111.   def update_target_selection
  112.     if Input.trigger?(Input::B)
  113.       Sound.play_cancel
  114.       if $game_party.item_number(@item) == 0    # 判断物品是否耗尽
  115.         @item_window.refresh                    # 刷新窗口内容      
  116.         @max_window.refresh                     # 刷新物品种类窗口
  117.       end
  118.       hide_target_window
  119.     elsif Input.trigger?(Input::C)
  120.       if not $game_party.item_can_use?(@item)
  121.         Sound.play_buzzer
  122.       else
  123.         determine_target
  124.       end
  125.     end
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ★ 更新指令选择
  129.   #--------------------------------------------------------------------------
  130.   def update_command_selection
  131.     if Input.trigger?(Input::B)
  132.       Sound.play_cancel
  133.       hide_command_window
  134.     elsif Input.trigger?(Input::C)
  135.       if @command_window.index == 0
  136.         if $game_party.item_can_use?(@item)
  137.           Sound.play_decision
  138.           @command_window.active = false
  139.           @command_window.visible =false
  140.           determine_item
  141.         else
  142.           Sound.play_buzzer
  143.         end
  144.       elsif  @item == nil or @item.price == 0
  145.         Sound.play_buzzer
  146.       else
  147.         Sound.play_decision
  148.         @command_window.active = false
  149.         @command_window.visible =false        
  150.         max = $game_party.item_number(@item)
  151.         @number_window.set(@item, max)
  152.         show_number_window
  153.       end
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ★ 更新数量输入
  158.   #--------------------------------------------------------------------------
  159.   def update_number_selection   
  160.     if Input.trigger?(Input::B)
  161.       Sound.play_cancel
  162.       hide_number_window
  163.     elsif Input.trigger?(Input::C)
  164.       Audio.se_play("Audio/SE/#{LOSE_ITEM_SE_NAME}", 80, 100)
  165.       $game_party.lose_item(@item, @number_window.number)
  166.       @item_window.refresh
  167.       @max_window.refresh  
  168.       hide_number_window
  169.     end  
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ★ 显示指令选择窗口
  173.   #--------------------------------------------------------------------------
  174.   def show_command_window
  175.     @command_window.index = 0
  176.     @item_window.active = false
  177.     @command_window.visible = true
  178.     @command_window.active = true
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ★ 显示数量窗口
  182.   #--------------------------------------------------------------------------
  183.   def show_number_window
  184.     @command_window.active = false
  185.     @number_window.visible = true
  186.     @number_window.active = true
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ★ 隐藏指令选择窗口
  190.   #--------------------------------------------------------------------------
  191.   def hide_command_window
  192.     @item_window.active = true
  193.     @command_window.visible = false
  194.     @command_window.active = false
  195.     @viewport.rect.set(0, 0, 544, 416)
  196.     @viewport.ox = 0
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ★ 隐藏数量窗口
  200.   #--------------------------------------------------------------------------
  201.   def hide_number_window
  202.     @item_window.active = true
  203.     @number_window.visible = false
  204.     @number_window.active = false
  205.     @viewport.rect.set(0, 0, 544, 416)
  206.     @viewport.ox = 0
  207.   end  
  208. end
  209. #==============================================================================
  210. # ■ Window_lost_item  
  211. #------------------------------------------------------------------------------
  212. #  显示物品丢弃数量的窗口,仿 Window_ShopNumber。
  213. #==============================================================================
  214. class Window_LoseNumber < Window_Base
  215.   #--------------------------------------------------------------------------
  216.   # ★ 初始化对像
  217.   #     x      : 窗口 X 座标
  218.   #     y      : 窗口 Y 座标
  219.   #--------------------------------------------------------------------------
  220.   def initialize(x, y)
  221.     super(x, y, 260, 104)
  222.     @item = nil
  223.     @max = 1
  224.     @number = 1
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ★ 设置物品、最大数量
  228.   #--------------------------------------------------------------------------
  229.   def set(item, max)
  230.     @item = item
  231.     @max = max
  232.     @number = 1
  233.     refresh
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ★ 设置数量输入
  237.   #--------------------------------------------------------------------------
  238.   def number
  239.     return @number
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ★ 刷新
  243.   #--------------------------------------------------------------------------
  244.   def refresh
  245.     y = 24
  246.     self.contents.clear
  247.     draw_item_name(@item, 0, y)
  248.     self.contents.font.color = normal_color
  249.     self.contents.draw_text(164, y, 20, WLH, "×")
  250.     self.contents.draw_text(190, y, 20, WLH, @number, 2)
  251.     self.cursor_rect.set(186, y, 28, WLH)
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # ★ 更新画面
  255.   #--------------------------------------------------------------------------
  256.   def update
  257.     super
  258.     if self.active
  259.       last_number = @number
  260.       if Input.repeat?(Input::RIGHT) and @number < @max
  261.         @number += 1
  262.       end
  263.       if Input.repeat?(Input::LEFT) and @number > 1
  264.         @number -= 1
  265.       end
  266.       if Input.repeat?(Input::UP) and @number < @max
  267.         @number = [@number + 10, @max].min
  268.       end
  269.       if Input.repeat?(Input::DOWN) and @number > 1
  270.         @number = [@number - 10, 1].max
  271.       end
  272.       if @number != last_number
  273.         Sound.play_cursor
  274.         refresh
  275.       end
  276.     end
  277.   end
  278. end
  279. #==============================================================================
  280. # ■ Window_Item_Max
  281. #-----------------------------------------------------------------------------
  282. #   显示背包容量和当前物品数的窗口
  283. #============================================================================

  284. class Window_Item_Max < Window_Base
  285.   #--------------------------------------------------------------------------
  286.   # ★ 初始化对像
  287.   #--------------------------------------------------------------------------
  288.   def initialize
  289.     super(290, 360, 254, 56)
  290.     refresh
  291.   end
  292.   
  293.   #--------------------------------------------------------------------------
  294.   # ★ 刷新
  295.   #--------------------------------------------------------------------------  
  296.   def refresh
  297.     self.contents.clear
  298.     draw_icon(144, 0, 0)
  299.     self.contents.draw_text(36, 0, 100, 24, "背包容量:")
  300.     item = $game_party.items
  301.     string = item.size.to_s
  302.     self.contents.font.color = knockout_color if item.size > $game_variables[IM]
  303.     self.contents.draw_text(135, 0, 30, 24, string, 2)
  304.     self.contents.font.color = normal_color
  305.     string = "/ " + $game_variables[IM].to_s
  306.     self.contents.draw_text(173, 0, 100, 24, string )
  307.   end
  308. end
  309. #==============================================================================
  310. # ■ Window_Waring
  311. #-----------------------------------------------------------------------------
  312. #   显示超重警告的窗口
  313. #============================================================================
  314. class Window_Waring  < Window_Base
  315.   def initialize
  316.     width = WARING_STRING.size * 8
  317.     super(544 - width, 416 - 56, width, 56)
  318.     refresh
  319.   end
  320.   
  321.   def refresh
  322.     self.contents.clear
  323.     self.contents.draw_text(0, -4, width - 32, 32, WARING_STRING)
  324.   end
  325. end
  326. #==============================================================================
  327. # Game_Player 添加更改移动速度的方法
  328. #============================================================================
  329. class Game_Player   
  330.   def change_move_speed(n)
  331.     @move_speed = n
  332.   end
  333. end
  334. #==============================================================================
  335. # Scene_Map  添加在地图上显示警告窗口的处理
  336. #============================================================================
  337. class Scene_Map
  338.   #--------------------------------------------------------------------------
  339.   # ● 开始处理
  340.   #--------------------------------------------------------------------------
  341.   alias start2 start
  342.   def start
  343.     start2
  344.     @waring_window = Window_Waring.new
  345.     @waring_window.visible = false
  346.   end  
  347.   #--------------------------------------------------------------------------
  348.   # ● 结束处理
  349.   #--------------------------------------------------------------------------
  350.   alias terminate2 terminate
  351.   def terminate
  352.     @waring_window.dispose
  353.     terminate2
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● フレーム更新
  357.   #--------------------------------------------------------------------------
  358.   alias update2 update
  359.   def update
  360.     update2
  361.     update_over_item
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 更新物品超限判定
  365.   #--------------------------------------------------------------------------  
  366.   def update_over_item
  367.     if $game_party.items.size > $game_variables[IM]
  368.       @waring_window.visible = true
  369.       $game_player.change_move_speed(LOW_SPEED)
  370.     else
  371.       @waring_window.visible = false
  372.     end
  373.   end
  374. end
复制代码
以上这个是VX的背包系统,求高手帮忙移植到VA,万分感激~!

最佳答案

查看完整内容

帮你做好了,好辛苦的说! 与原脚本功能完全相同! 范例地址:http://pan.baidu.com/share/link?shareid=132430&uk=875076719 截图: 脚本:

Lv3.寻梦者 (版主)

八宝粥的基叔

梦石
0
星屑
4509
在线时间
5228 小时
注册时间
2009-4-29
帖子
14318

贵宾

2
发表于 2012-11-6 23:05:36 | 只看该作者
本帖最后由 protosssonny 于 2012-11-10 16:04 编辑

帮你做好了,好辛苦的说!
与原脚本功能完全相同!
范例地址:http://pan.baidu.com/share/link?shareid=132430&uk=875076719
截图:



脚本:
  1. #==============================================================================
  2. # ■ 背包系统VA移植版
  3. #------------------------------------------------------------------------------
  4. #   备注:【protosssonny】将【水镜风生】的背包系统VX版的功能移植到VA系统
  5. #
  6. #   本脚本来自www.66RPG.com,使用和转载请保留此信息
  7. #
  8. #   作者:protosssonny   
  9. #
  10. #==============================================================================
  11. # ☆ 参数设定
  12.   LOSE_ITEM_SE_NAME = "Evasion1"        # 丢弃物品时播放的SE
  13.   LOW_SPEED = 2                         # 背包塞满时的移动速度
  14.   USUAL_SPEED = 4                       # 平时的移动速度
  15.   WARING_STRING = "背包放的东西太多了。" # 超重时的提示
  16.   IM = 1                                # IM号系统变量决定物品种类的最大值
  17. #==============================================================================


  18. #==============================================================================
  19. # ■ Window_Window_ThrowNumber
  20. #------------------------------------------------------------------------------
  21. #  丢弃物品命令时中,输入“丢弃数量”的窗口。
  22. #==============================================================================

  23. class Window_ThrowNumber < Window_Selectable
  24.   #--------------------------------------------------------------------------
  25.   # ● 定义实例变量
  26.   #--------------------------------------------------------------------------
  27.   attr_reader   :number                   # 数量
  28.   #--------------------------------------------------------------------------
  29.   # ● 初始化对象
  30.   #--------------------------------------------------------------------------
  31.   def initialize(x, y, height)
  32.     super(x, y, window_width, height)
  33.     @item = nil
  34.     @max = 1
  35.     @price = 0
  36.     @number = 1
  37.     @currency_unit = Vocab::currency_unit
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 获取窗口的宽度
  41.   #--------------------------------------------------------------------------
  42.   def window_width
  43.     return 304
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 设置物品、最大值、价格、货币单位
  47.   #--------------------------------------------------------------------------
  48.   def set(item, max, price)
  49.     @item = item
  50.     @max = max
  51.     @price = price
  52.     @number = 1
  53.     refresh
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 设置货币单位
  57.   #--------------------------------------------------------------------------
  58.   def currency_unit=(currency_unit)
  59.     @currency_unit = currency_unit
  60.     refresh
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 刷新
  64.   #--------------------------------------------------------------------------
  65.   def refresh
  66.     contents.clear
  67.     draw_item_name(@item, 0, item_y)
  68.     draw_number
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 绘制数量
  72.   #--------------------------------------------------------------------------
  73.   def draw_number
  74.     change_color(normal_color)
  75.     draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  76.     draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  77.   end
  78.   #--------------------------------------------------------------------------
  79.   # ● 显示物品名称行的 Y 坐标
  80.   #--------------------------------------------------------------------------
  81.   def item_y
  82.     contents_height / 2 - line_height * 3 / 2
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 显示价格行的 Y 坐标
  86.   #--------------------------------------------------------------------------
  87.   def price_y
  88.     contents_height / 2 + line_height / 2
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 获取光标的宽度
  92.   #--------------------------------------------------------------------------
  93.   def cursor_width
  94.     figures * 10 + 12
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 获取光标的 X 坐标
  98.   #--------------------------------------------------------------------------
  99.   def cursor_x
  100.     contents_width - cursor_width - 4
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 获取数量显示的最大列数
  104.   #--------------------------------------------------------------------------
  105.   def figures
  106.     return 2
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 更新画面
  110.   #--------------------------------------------------------------------------
  111.   def update
  112.     super
  113.     if active
  114.       last_number = @number
  115.       update_number
  116.       if @number != last_number
  117.         Sound.play_cursor
  118.         refresh
  119.       end
  120.     end
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 更新数量
  124.   #--------------------------------------------------------------------------
  125.   def update_number
  126.     change_number(1)   if Input.repeat?(:RIGHT)
  127.     change_number(-1)  if Input.repeat?(:LEFT)
  128.     change_number(10)  if Input.repeat?(:UP)
  129.     change_number(-10) if Input.repeat?(:DOWN)
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # ● 更改数量
  133.   #--------------------------------------------------------------------------
  134.   def change_number(amount)
  135.     @number = [[@number + amount, @max].min, 1].max
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 更新光标
  139.   #--------------------------------------------------------------------------
  140.   def update_cursor
  141.     cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
  142.   end
  143. end


  144. #==============================================================================
  145. # ■ Window_Item_Number_State
  146. #------------------------------------------------------------------------------
  147. #  显示物品持有数量以及负重状态文字
  148. #==============================================================================

  149. class Window_Item_Number_State < Window_Base
  150.   #--------------------------------------------------------------------------
  151.   # ● 初始化对象
  152.   #--------------------------------------------------------------------------
  153.   def initialize
  154.     super(0, Graphics.height - 54, Graphics.width, 54)
  155.     refresh
  156.   end
  157.   def refresh
  158.     self.contents.clear
  159.     contents.draw_text(0, 0, 300, 24, "物品种类:" )
  160.     contents.font.color = text_color(18) if $game_player.slow_move
  161.     contents.draw_text(120, 0, 36, 24, "#{$game_party.all_items.size.to_s}", 2)
  162.     contents.font.color = text_color(0)
  163.     contents.draw_text(156, 0, 36, 24, "/#{$game_variables[IM]}")
  164.     contents.draw_text(200, 0, 328, 24, WARING_STRING, 2) if $game_player.slow_move
  165.   end
  166. end  


  167. #==============================================================================
  168. # ■ Scene_Item
  169. #------------------------------------------------------------------------------
  170. #  物品画面
  171. #==============================================================================

  172. class Scene_Item < Scene_ItemBase
  173.   #--------------------------------------------------------------------------
  174.   # ● 开始处理
  175.   #--------------------------------------------------------------------------
  176.   def start
  177.     super
  178.     create_help_window
  179.     create_category_window
  180.     create_item_window
  181.     create_number_window
  182.     @item_number_state_window = Window_Item_Number_State.new
  183.     @item_number_state_window.z = 0
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● 生成分类窗口
  187.   #--------------------------------------------------------------------------
  188.   def create_category_window
  189.     @category_window = Window_ItemCategory.new
  190.     @category_window.viewport = @viewport
  191.     @category_window.help_window = @help_window
  192.     @category_window.y = @help_window.height
  193.     @category_window.set_handler(:ok,     method(:on_category_ok))
  194.     @category_window.set_handler(:cancel, method(:return_scene))
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 生成物品窗口
  198.   #--------------------------------------------------------------------------
  199.   def create_item_window
  200.     wy = @category_window.y + @category_window.height
  201.     wh = Graphics.height - wy
  202.     @item_window = Window_ItemList.new(0, wy, Graphics.width, wh - 54)
  203.     @item_window.viewport = @viewport
  204.     @item_window.help_window = @help_window
  205.     @item_window.set_handler(:ok,     method(:on_item_choose))
  206.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  207.     @category_window.item_window = @item_window
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 生成物品命令窗口
  211.   #--------------------------------------------------------------------------
  212.   def create_item_command_window
  213.     @item_command_window = Window_Item_Operate.new
  214.     @item_command_window.x = 200
  215.     @item_command_window.y = 160
  216.     @item_command_window.z = 250
  217.     @item_window.viewport = @viewport
  218.     @item_command_window.hide
  219.     @item_command_window.set_handler(:ok,     method(:on_item_ok))
  220.     @item_command_window.set_handler(:cancel, method(:on_item_cancel))
  221.   end  
  222.   #--------------------------------------------------------------------------
  223.   # ● 生成数值输入窗口
  224.   #--------------------------------------------------------------------------
  225.   def create_number_window
  226.     @number_window = Window_ThrowNumber.new(0, 160, 200)
  227.     @number_window.x = 200
  228.     @number_window.y = 160
  229.     @number_window.z = 250
  230.     @number_window.viewport = @viewport
  231.     @number_window.hide
  232.     @number_window.set_handler(:ok,     method(:on_number_ok))
  233.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 分类“确定”
  237.   #--------------------------------------------------------------------------
  238.   def on_category_ok
  239.     @item_window.activate
  240.     @item_window.select_last
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 物品“选择”
  244.   #--------------------------------------------------------------------------
  245.   def on_item_choose
  246.     @item_window.deactivate
  247.     create_item_command_window
  248.     @item_command_window.show.activate
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 物品“确定”
  252.   #--------------------------------------------------------------------------
  253.   def on_item_ok
  254.     if @item_command_window.index == 0
  255.       $game_party.last_item.object = item
  256.       @item_command_window.hide.deactivate
  257.       determine_item
  258.     elsif @item_command_window.index == 1
  259.       @number_window.set(item, $game_party.item_number(item), item.price)
  260.       @number_window.show.activate
  261.       @item_command_window.hide.deactivate
  262.     end  
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● 物品“取消”
  266.   #--------------------------------------------------------------------------
  267.   def on_item_cancel
  268.     @item_window.unselect
  269.     @category_window.activate
  270.     @item_command_window.hide.deactivate unless @item_command_window.nil?
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 数量输入“确定”
  274.   #--------------------------------------------------------------------------
  275.   def on_number_ok
  276.     $game_party.gain_item(item, - @number_window.number)
  277.     @number_window.hide.deactivate
  278.     @item_window.activate
  279.     @item_window.refresh
  280.     @item_number_state_window.refresh
  281.     Audio.se_play("Audio/SE/#{LOSE_ITEM_SE_NAME}", 80, 100)
  282.   end  
  283.   #--------------------------------------------------------------------------
  284.   # ● 数量输入“取消”
  285.   #--------------------------------------------------------------------------
  286.   def on_number_cancel
  287.     @number_window.hide.deactivate
  288.     @item_window.activate
  289.   end  
  290.   #--------------------------------------------------------------------------
  291.   # ● 播放使用物品声效
  292.   #--------------------------------------------------------------------------
  293.   def play_se_for_item
  294.     Sound.play_use_item
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 使用物品
  298.   #--------------------------------------------------------------------------
  299.   def use_item
  300.     super
  301.     @item_window.redraw_current_item
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● 隐藏指令选择窗口
  305.   #--------------------------------------------------------------------------
  306.   def hide_item_command_window
  307.     @item_window.activate
  308.     @item_command_window.hide.deactivate
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 读取物品窗口
  312.   #--------------------------------------------------------------------------
  313.   def item_window
  314.     @item_window
  315.   end  
  316. end

  317. class Window_Item_Operate < Window_Command
  318.   #--------------------------------------------------------------------------
  319.   # ● 初始化对象
  320.   #--------------------------------------------------------------------------
  321.   def initialize
  322.     super(0, 0)
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● 获取窗口的宽度
  326.   #--------------------------------------------------------------------------
  327.   def window_width
  328.     return 160
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # ● 获取显示行数
  332.   #--------------------------------------------------------------------------
  333.   def visible_line_number
  334.     item_max
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 生成指令列表
  338.   #--------------------------------------------------------------------------
  339.   def make_command_list
  340.     add_main_commands
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 向指令列表添加主要的指令
  344.   #--------------------------------------------------------------------------
  345.   def add_main_commands
  346.     add_command("使用",   :item,   use_ok)
  347.     add_command("丢弃",   :throw,  throw_ok)
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 物品使用限制判定
  351.   #--------------------------------------------------------------------------
  352.   def use_ok
  353.     main_item = SceneManager.scene::item_window.item
  354.     if main_item
  355.       if main_item.is_a?(RPG::Item)
  356.         if $game_party.usable?(main_item)
  357.           true
  358.         else  
  359.           false
  360.         end
  361.       else   
  362.         false
  363.       end  
  364.     else   
  365.       false
  366.     end
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ● 物品可丢弃判定
  370.   #--------------------------------------------------------------------------
  371.   def throw_ok
  372.     if SceneManager.scene::item_window.item
  373.       SceneManager.scene::item_window.item.price > 0
  374.     else
  375.       false
  376.     end  
  377.   end  
  378. end  


  379. #==============================================================================
  380. # ■ Window_ItemList
  381. #------------------------------------------------------------------------------
  382. #  物品画面中,显示持有物品的窗口。
  383. #==============================================================================

  384. class Window_ItemList < Window_Selectable
  385.   #--------------------------------------------------------------------------
  386.   # ● 查询此物品是否可用
  387.   #--------------------------------------------------------------------------
  388.   def enable?(item)
  389.     true
  390.   end
  391. end  


  392. #==============================================================================
  393. # ■ Game_Party
  394. #------------------------------------------------------------------------------
  395. #  管理队伍的类。保存有金钱及物品的信息。本类的实例请参考 $game_party 。
  396. #==============================================================================

  397. class Game_Party < Game_Unit  
  398.   #--------------------------------------------------------------------------
  399.   # ● 增加/减少物品
  400.   #     include_equip : 是否包括装备
  401.   #--------------------------------------------------------------------------
  402.   def gain_item(item, amount, include_equip = false)
  403.     container = item_container(item.class)
  404.     return unless container
  405.     last_number = item_number(item)
  406.     new_number = last_number + amount
  407.     container[item.id] = [[new_number, 0].max, max_item_number(item)].min
  408.     container.delete(item.id) if container[item.id] == 0
  409.     if include_equip && new_number < 0
  410.       discard_members_equip(item, -new_number)
  411.     end
  412.     $game_player.slow_move
  413.     $game_map.need_refresh = true
  414.   end
  415. end


  416. #==============================================================================
  417. # ■ Game_Player
  418. #------------------------------------------------------------------------------
  419. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
  420. #   本类的实例请参考 $game_player 。
  421. #==============================================================================

  422. class Game_Player < Game_Character
  423.   def slow_move
  424.     if $game_party.all_items.size > $game_variables[IM]
  425.       @move_speed = LOW_SPEED
  426.       true
  427.     else
  428.       @move_speed = USUAL_SPEED
  429.       false
  430.     end
  431.   end
  432. end  


  433. #==============================================================================
  434. #
  435. #   本脚本来自www.66RPG.com,使用和转载请保留此信息
  436. #
  437. #                                                          作者:protosssonny   
  438. #                                                             2012年11月9日
  439. #==============================================================================
复制代码

点评

有那么恐怖吗?喵~[url=home.php?mod=space&username=布兰度西特]@布兰度西特[/url]  发表于 2012-11-12 15:50
P叔你再进化的话就逆天了~  发表于 2012-11-12 14:34

评分

参与人数 2星屑 +84 收起 理由
xuzhengchi + 24 测试可用,不胜感激~3V请笑纳~
八宝粥先生 + 60 P叔牛人...

查看全部评分

《逝去的回忆3:四叶草之梦》真情发布,欢迎点击图片下载试玩喵。

《逝去的回忆3》的讨论群:
一群:192885514
二群:200460747
回复

使用道具 举报

Lv3.寻梦者

伴侣:北岛谜烟

梦石
0
星屑
2892
在线时间
3547 小时
注册时间
2012-8-7
帖子
12181

贵宾

3
发表于 2012-11-7 12:37:22 | 只看该作者
改什么的要重新定制……我只知道搬运

丢弃物品脚本
  1. #==============================================================================
  2. # ■ VXAce-RGSS3-2 アイテム捨てる [Ver.1.0.0]         by Claimh
  3. #------------------------------------------------------------------------------
  4. #  アイテム画面上でXボタンを押すと、アイテムを捨てることができます。
  5. #==============================================================================


  6. #==============================================================================
  7. # ■ Window_ItemList
  8. #==============================================================================
  9. class Window_ItemList < Window_Selectable
  10.   #--------------------------------------------------------------------------
  11.   # ● 決定やキャンセルなどのハンドリング処理
  12.   #--------------------------------------------------------------------------
  13.   def process_handling
  14.     return unless open? && active
  15.     return call_handler(:append_x)   if handle?(:append_x) && Input.trigger?(:X)
  16.     super
  17.   end
  18. end

  19. #==============================================================================
  20. # ■ Window_ItemNumber
  21. #==============================================================================
  22. class Window_ItemNumber < Window_ShopNumber
  23.   #--------------------------------------------------------------------------
  24.   # ● 公開インスタンス変数
  25.   #--------------------------------------------------------------------------
  26.   attr_reader   :number                   # 入力された個数
  27.   #--------------------------------------------------------------------------
  28.   # ● オブジェクト初期化
  29.   #--------------------------------------------------------------------------
  30.   def initialize
  31.     x = (Graphics.width - window_width) / 2
  32.     super(x, 200, line_height*2 + 32)
  33.     @item = nil
  34.     @max = 1
  35.     @number = 1
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● アイテム、最大個数の設定
  39.   #--------------------------------------------------------------------------
  40.   def set(item, max)
  41.     @item = item
  42.     @max = max
  43.     @number = 1
  44.     refresh
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● リフレッシュ
  48.   #--------------------------------------------------------------------------
  49.   def refresh
  50.     contents.clear
  51.     contents.draw_text(0, 0, 200, line_height, "捨てる数:")
  52.     draw_item_name(@item, 4, line_height)
  53.     draw_number
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● アイテム名表示行の Y 座標
  57.   #--------------------------------------------------------------------------
  58.   def item_y
  59.     line_height
  60.   end
  61. end


  62. #==============================================================================
  63. # ■ Scene_Item
  64. #==============================================================================
  65. class Scene_Item < Scene_ItemBase
  66.   #--------------------------------------------------------------------------
  67.   # ● 開始処理
  68.   #--------------------------------------------------------------------------
  69.   alias start_dump start
  70.   def start
  71.     start_dump
  72.     create_item_dump_window
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● アイテムウィンドウの作成
  76.   #--------------------------------------------------------------------------
  77.   alias create_item_window_dump create_item_window
  78.   def create_item_window
  79.     create_item_window_dump
  80.     @item_window.set_handler(:append_x, method(:on_item_dump))
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● アイテム数選択ウィンドウの作成
  84.   #--------------------------------------------------------------------------
  85.   def create_item_dump_window
  86.     @number_window = Window_ItemNumber.new
  87.     @number_window.viewport = @viewport
  88.     @number_window.hide
  89.     @number_window.set_handler(:ok,     method(:on_number_ok))
  90.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● アイテム[捨てる]
  94.   #--------------------------------------------------------------------------
  95.   def on_item_dump
  96.     if item_dumpable?
  97.       Sound.play_ok
  98.       @number_window.set(item, max_item)
  99.       @number_window.show.activate
  100.       @item_window.deactivate
  101.     else
  102.       Sound.play_buzzer
  103.     end
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 個数入力[決定]
  107.   #--------------------------------------------------------------------------
  108.   def on_number_ok
  109.     Sound.play_ok
  110.     do_item_dump(@number_window.number)
  111.     @number_window.hide
  112.     activate_item_window
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 個数入力[キャンセル]
  116.   #--------------------------------------------------------------------------
  117.   def on_number_cancel
  118.     Sound.play_cancel
  119.     @number_window.hide
  120.     activate_item_window
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 捨てるの実行
  124.   #--------------------------------------------------------------------------
  125.   def do_item_dump(number)
  126.     $game_party.lose_item(item, number)
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● アイテムを捨てる判定
  130.   #--------------------------------------------------------------------------
  131.   def item_dumpable?
  132.     item.is_a?(RPG::Item) ? !item.key_item? : (!item.nil?)
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 所持数の取得
  136.   #--------------------------------------------------------------------------
  137.   def max_item
  138.     $game_party.item_number(item)
  139.   end
  140. end


复制代码
载重的找不到
本人收不到提醒(点评|回复|@人),总之有事情到空间留言一起普通普通
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
149
在线时间
664 小时
注册时间
2011-9-25
帖子
241
4
 楼主| 发表于 2012-11-7 12:53:11 | 只看该作者
delv25 发表于 2012-11-7 12:37
改什么的要重新定制……我只知道搬运

丢弃物品脚本载重的找不到

多谢哈~其实主要就是想要那个限制背包数量的功能,就是像VX的那样。是不是V给少了……

点评

已经很多了  发表于 2012-11-7 12:57
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
743
在线时间
2064 小时
注册时间
2011-10-3
帖子
1686
5
发表于 2012-11-8 20:30:52 | 只看该作者
限制物品数量的话搜索下上限脚本

点评

是限制种类的数目,并非单个物品的数量  发表于 2012-11-8 21:35
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
743
在线时间
2064 小时
注册时间
2011-10-3
帖子
1686
6
发表于 2012-11-8 22:38:25 | 只看该作者
把一个种类的物品的数量都改一改就是一个种类了
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
149
在线时间
664 小时
注册时间
2011-9-25
帖子
241
7
 楼主| 发表于 2012-11-10 08:59:06 | 只看该作者
protosssonny 发表于 2012-11-9 22:17
帮你做好了,好辛苦的说!
与原脚本功能完全相同!
范例地址:http://pan.baidu.com/sh ...

非常感谢~
有个小问题:当在物品上按取消键有时就会报错,如下图所示:

请问该怎么改~

点评

BUG已经修正。范例工程和以上脚本都已经更新。  发表于 2012-11-10 16:05
回复

使用道具 举报

Lv3.寻梦者

伴侣:北岛谜烟

梦石
0
星屑
2892
在线时间
3547 小时
注册时间
2012-8-7
帖子
12181

贵宾

8
发表于 2012-11-11 17:27:47 | 只看该作者
  1. class RPG::BaseItem
  2.   def load
  3.     return if self.is_a?(RPG::Skill)
  4.     self.note.split(/[\r\n]+/).each { |line|
  5.       if line =~ /\[(?:load|负重|負重) (\w+)\]/
  6.         return $1.nil? ? 0 : $1.to_i
  7.       end}
  8.     return 0
  9.   end
  10. end
  11. class Scene_Item < Scene_ItemBase
  12.   alias load_start start
  13.   alias load_terminate terminate
  14.   alias load_update update
  15.   def start
  16.     load_start
  17.     @load_window = Window_Base.new(392, 0, 152, 56)
  18.     @load_window.viewport = @viewport
  19.   end
  20.   def terminate
  21.     @load_window.dispose
  22.     load_terminate
  23.   end
  24.   def update
  25.     @load_window.update
  26.     if @temp_load != $game_party.current_load
  27.       @load_window.contents.clear
  28.       @load_window.contents.draw_text(0, 0, 120, 24, "负重:#{$game_party.current_load}/#{$game_party.total_load}")
  29.       @temp_load = $game_party.current_load
  30.     end
  31.     if Input.trigger?(Input::X)
  32.       @item = @item_window.item
  33.       $game_party.lose_item(@item, 1)
  34.       @item_window.refresh
  35.     end
  36.     load_update
  37.   end
  38. end
  39. class Scene_Shop < Scene_MenuBase
  40.   alias load_start start
  41.   alias load_terminate terminate
  42.   alias load_update update
  43.   def start
  44.     load_start
  45.     @load_window = Window_Base.new(392, 0, 152, 56)
  46.     @load_window.viewport = @viewport
  47.   end
  48.   def terminate
  49.     @load_window.dispose
  50.     load_terminate
  51.   end
  52.   def update
  53.     @load_window.update
  54.     if @temp_load != $game_party.current_load
  55.       @load_window.contents.clear
  56.       @load_window.contents.draw_text(0, 0, 120, 24, "负重:#{$game_party.current_load}/#{$game_party.total_load}")
  57.       @temp_load = $game_party.current_load
  58.     end
  59.     load_update
  60.   end
  61. end
  62. class Game_Party < Game_Unit
  63.   attr_reader :current_load
  64.   alias load_initialize initialize
  65.   alias load_gain_item gain_item
  66.   def initialize
  67.     load_initialize
  68.     @current_load = 0
  69.   end
  70.   # 获取队伍最大负重
  71.   def total_load
  72.     party_load = 0
  73.     #members.size.times do |i|
  74.     for i in 0...members.size
  75.       actor = members[i]
  76.       party_load += actor.load
  77.     end
  78.     return party_load
  79.   end
  80.   def gain_item(item, n, include_equip = false)
  81.     return if item.nil?
  82.     if ((item.load * n) + @current_load) > total_load
  83.       $game_message.texts.push("靠!负重都不足了,你妹的怎么还不赶快清空物品!")
  84.       $game_message.visible = true
  85.       return
  86.     else
  87.       @current_load += item.load * n
  88.     end
  89.     load_gain_item(item, n, include_equip)
  90.   end
  91. end
  92. class Game_Actor < Game_Battler
  93.   # 获取队员负重
  94.   def load
  95.     return (mhp + mmp) * @level / agi
  96.   end
  97. end
  98. class Game_Interpreter
  99.   alias load_command_126 command_126
  100.   alias load_command_127 command_127
  101.   alias load_command_128 command_128
  102.   def command_126
  103.     n = operate_value(@params[1], @params[2], @params[3])
  104.     return command_115 if check_load(@params[0], 0, n)
  105.     load_command_126
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 增減武器
  109.   #--------------------------------------------------------------------------
  110.   def command_127
  111.     n = operate_value(@params[1], @params[2], @params[3])
  112.     return command_115 if check_load(@params[0], 1, n)
  113.     load_command_127
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 增減防具
  117.   #--------------------------------------------------------------------------
  118.   def command_128
  119.     n = operate_value(@params[1], @params[2], @params[3])
  120.     return command_115 if check_load(@params[0], 2, n)
  121.     load_command_128
  122.   end
  123.   def check_load(item_id, type, n)
  124.     case type
  125.     when 0; item = $data_items[item_id]
  126.     when 1; item = $data_weapons[item_id]
  127.     when 2; item = $data_armors[item_id]
  128.     end
  129.     if (((item.load * n) + $game_party.current_load) > $game_party.total_load)
  130.       $game_message.texts.push("太重拉,按下Q丢弃物品!")
  131.       $game_message.visible = true
  132.       return true
  133.     end
  134.     return false
  135.   end
  136. end
复制代码
本人收不到提醒(点评|回复|@人),总之有事情到空间留言一起普通普通
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-7 13:17

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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