查看: 1926|回复: 2

[已经解决] 负重脚本的问题

[复制链接]
梦石
0
星屑
6963
在线时间
1557 小时
注册时间
2011-6-14
回帖
425
发表于 2015-9-30 09:20:33 | 显示全部楼层 |阅读模式

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

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

×
这个脚本按下A键就会自动丢弃物品 我想取消掉这个功能

[pre lang="ruby"]
class RPG::BaseItem
  def load
    return if self.is_a?(RPG::Skill)
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[(?:load|负重|負重) (\w+)\]/
        return $1.nil? ? 0 : $1.to_i
      end}
    return 0
  end
end

class Scene_Item < Scene_ItemBase
  alias load_start start
  alias load_terminate terminate
  alias load_update update
  def start
    load_start
    @load_window = Window_Base.new(392, 0, 152, 56)
    @load_window.viewport = @viewport
  end
  def terminate
    @load_window.dispose
    load_terminate
  end
  def update
    @load_window.update
    if @temp_load != $game_party.current_load
      @load_window.contents.clear
      @load_window.contents.draw_text(0, 0, 120, 24, "负重:#{$game_party.current_load}/#{$game_party.total_load}")
      @temp_load = $game_party.current_load
    end
    if Input.trigger?(Input::X)
      @item = @item_window.item
      $game_party.lose_item(@item, 1)
      @item_window.refresh
    end
    load_update
  end
end

class Scene_Shop < Scene_MenuBase
  alias load_start start
  alias load_terminate terminate
  alias load_update update
  def start
    load_start
    @load_window = Window_Base.new(392, 0, 152, 56)
    @load_window.viewport = @viewport
  end
  def terminate
    @load_window.dispose
    load_terminate
  end
  def update
    @load_window.update
    if @temp_load != $game_party.current_load
      @load_window.contents.clear
      @load_window.contents.draw_text(0, 0, 120, 24, "负重:#{$game_party.current_load}/#{$game_party.total_load}")
      @temp_load = $game_party.current_load
    end
    load_update
  end
end

class Game_Party < Game_Unit
  attr_reader :current_load
  alias load_initialize initialize
  alias load_gain_item gain_item
  def initialize
    load_initialize
    @current_load = 0
  end
  # 获取队伍最大负重
  def total_load
    party_load = 0
    #members.size.times do |i|
    for i in 0...members.size
      actor = members
      party_load += actor.load
    end
    return party_load
   
  end

  def gain_item(item, n, include_equip = false)
    return if item.nil?
      load_gain_item(item, n, include_equip)
      @current_load += item.load * n
  end
end
class Game_Actor < Game_Battler
  # 获取队员负重
  def load
    return (mhp + mmp) * @level / agi
  end
end
class Game_Interpreter
  alias load_command_126 command_126
  alias load_command_127 command_127
  alias load_command_128 command_128
  
  def command_126
    n = operate_value(@params[1], @params[2], @params[3])
    return command_115 if check_load(@params[0], 0, n)
    load_command_126
  end
  #--------------------------------------------------------------------------
  # ● 增減武器
  #--------------------------------------------------------------------------
  def command_127
    n = operate_value(@params[1], @params[2], @params[3])
    return command_115 if check_load(@params[0], 1, n)
    load_command_127
  end
  #--------------------------------------------------------------------------
  # ● 增減防具
  #--------------------------------------------------------------------------
  def command_128
    n = operate_value(@params[1], @params[2], @params[3])
    return command_115 if check_load(@params[0], 2, n)
    load_command_128
  end
  
  def check_load(item_id, type, n)
    case type
    when 0; item = $data_items[item_id]
    when 1; item = $data_weapons[item_id]
    when 2; item = $data_armors[item_id]
    end
    if (((item.load * n) + $game_party.current_load) > $game_party.total_load)
      $game_message.texts.push("负重已满,无法移动") if $game_message.visible != true
      $game_message.visible = true
    end
    return
  end
end
class Game_Player < Game_Character
  
  alias vipmovable? movable?
  #--------------------------------------------------------------------------
  # ● 判定是否负重已满
  #--------------------------------------------------------------------------
  def mfz_vip?
    $game_party.total_load < $game_party.current_load
  end
  #--------------------------------------------------------------------------
  # ● 判定是否可以移动
  #--------------------------------------------------------------------------
  def movable?
    return false if mfz_vip?
    vipmovable?
  end
end

class Window_ShopBuy < Window_Selectable
  
  #--------------------------------------------------------------------------
  # ● 判定是否负重已满
  #--------------------------------------------------------------------------
  def mfz_vip?
    $game_party.total_load <= $game_party.current_load
  end
  #--------------------------------------------------------------------------
  # ● 查询商品是否可买
  #--------------------------------------------------------------------------
  def enable?(item)
    item && price(item) <= @money && !$game_party.item_max?(item) && !mfz_vip?
  end
end
class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 获取可以买入的最大值
  #--------------------------------------------------------------------------
  def max_buy
    vip = ($game_party.total_load - $game_party.current_load) / @item.load
    max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
    buying_price == 0 ? [max,vip].min : [max,vip, money / buying_price].min
  end
end[/pre]

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2015-9-30 09:37:58 | 显示全部楼层
32-36行的代码删掉即可

点评

多谢大大  发表于 2015-9-30 09:47

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复

使用道具 举报

无限の剣制

梦石
0
星屑
10445
在线时间
5019 小时
注册时间
2013-2-28
回帖
4942

开拓者贵宾

发表于 2015-9-30 10:30:40 | 显示全部楼层
https://raw.githubusercontent.co ... 7%B3%BB%E7%BB%9F.rb
你可以试试这个新版的,应该会好看点,取消丢弃道具就把 Lose_SW设置为false

点评

咦,不过我觉得楼主的冲突多半和我include没关系。  发表于 2015-10-1 12:20
需要alias的class还是别include了吧……  发表于 2015-9-30 10:53
这个与我的脚本冲突了  发表于 2015-9-30 10:46
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部