Project1

标题: 负重脚本的问题 [打印本页]

作者: 347780682    时间: 2015-9-30 09:20
标题: 负重脚本的问题
这个脚本按下A键就会自动丢弃物品 我想取消掉这个功能

RUBY 代码复制
  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.  
  12. class Scene_Item < Scene_ItemBase
  13.   alias load_start start
  14.   alias load_terminate terminate
  15.   alias load_update update
  16.   def start
  17.     load_start
  18.     @load_window = Window_Base.new(392, 0, 152, 56)
  19.     @load_window.viewport = @viewport
  20.   end
  21.   def terminate
  22.     @load_window.dispose
  23.     load_terminate
  24.   end
  25.   def update
  26.     @load_window.update
  27.     if @temp_load != $game_party.current_load
  28.       @load_window.contents.clear
  29.       @load_window.contents.draw_text(0, 0, 120, 24, "负重:#{$game_party.current_load}/#{$game_party.total_load}")
  30.       @temp_load = $game_party.current_load
  31.     end
  32.     if Input.trigger?(Input::X)
  33.       @item = @item_window.item
  34.       $game_party.lose_item(@item, 1)
  35.       @item_window.refresh
  36.     end
  37.     load_update
  38.   end
  39. end
  40.  
  41. class Scene_Shop < Scene_MenuBase
  42.   alias load_start start
  43.   alias load_terminate terminate
  44.   alias load_update update
  45.   def start
  46.     load_start
  47.     @load_window = Window_Base.new(392, 0, 152, 56)
  48.     @load_window.viewport = @viewport
  49.   end
  50.   def terminate
  51.     @load_window.dispose
  52.     load_terminate
  53.   end
  54.   def update
  55.     @load_window.update
  56.     if @temp_load != $game_party.current_load
  57.       @load_window.contents.clear
  58.       @load_window.contents.draw_text(0, 0, 120, 24, "负重:#{$game_party.current_load}/#{$game_party.total_load}")
  59.       @temp_load = $game_party.current_load
  60.     end
  61.     load_update
  62.   end
  63. end
  64.  
  65. class Game_Party < Game_Unit
  66.   attr_reader :current_load
  67.   alias load_initialize initialize
  68.   alias load_gain_item gain_item
  69.   def initialize
  70.     load_initialize
  71.     @current_load = 0
  72.   end
  73.   # 获取队伍最大负重
  74.   def total_load
  75.     party_load = 0
  76.     #members.size.times do |i|
  77.     for i in 0...members.size
  78.       actor = members[i]
  79.       party_load += actor.load
  80.     end
  81.     return party_load
  82.  
  83.   end
  84.  
  85.   def gain_item(item, n, include_equip = false)
  86.     return if item.nil?
  87.       load_gain_item(item, n, include_equip)
  88.       @current_load += item.load * n
  89.   end
  90. end
  91. class Game_Actor < Game_Battler
  92.   # 获取队员负重
  93.   def load
  94.     return (mhp + mmp) * @level / agi
  95.   end
  96. end
  97. class Game_Interpreter
  98.   alias load_command_126 command_126
  99.   alias load_command_127 command_127
  100.   alias load_command_128 command_128
  101.  
  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.  
  124.   def check_load(item_id, type, n)
  125.     case type
  126.     when 0; item = $data_items[item_id]
  127.     when 1; item = $data_weapons[item_id]
  128.     when 2; item = $data_armors[item_id]
  129.     end
  130.     if (((item.load * n) + $game_party.current_load) > $game_party.total_load)
  131.       $game_message.texts.push("负重已满,无法移动") if $game_message.visible != true
  132.       $game_message.visible = true
  133.     end
  134.     return
  135.   end
  136. end
  137. class Game_Player < Game_Character
  138.  
  139.   alias vipmovable? movable?
  140.   #--------------------------------------------------------------------------
  141.   # ● 判定是否负重已满
  142.   #--------------------------------------------------------------------------
  143.   def mfz_vip?
  144.     $game_party.total_load < $game_party.current_load
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● 判定是否可以移动
  148.   #--------------------------------------------------------------------------
  149.   def movable?
  150.     return false if mfz_vip?
  151.     vipmovable?
  152.   end
  153. end
  154.  
  155. class Window_ShopBuy < Window_Selectable
  156.  
  157.   #--------------------------------------------------------------------------
  158.   # ● 判定是否负重已满
  159.   #--------------------------------------------------------------------------
  160.   def mfz_vip?
  161.     $game_party.total_load <= $game_party.current_load
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● 查询商品是否可买
  165.   #--------------------------------------------------------------------------
  166.   def enable?(item)
  167.     item && price(item) <= @money && !$game_party.item_max?(item) && !mfz_vip?
  168.   end
  169. end
  170. class Scene_Shop < Scene_MenuBase
  171.   #--------------------------------------------------------------------------
  172.   # ● 获取可以买入的最大值
  173.   #--------------------------------------------------------------------------
  174.   def max_buy
  175.     vip = ($game_party.total_load - $game_party.current_load) / @item.load
  176.     max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
  177.     buying_price == 0 ? [max,vip].min : [max,vip, money / buying_price].min
  178.   end
  179. end

作者: 喵呜喵5    时间: 2015-9-30 09:37
32-36行的代码删掉即可
作者: VIPArcher    时间: 2015-9-30 10:30
https://raw.githubusercontent.co ... 7%B3%BB%E7%BB%9F.rb
你可以试试这个新版的,应该会好看点,取消丢弃道具就把 Lose_SW设置为false




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1