查看: 2042|回复: 1

[已经解决] 如何設置武器、裝備為不可丟棄 (有腳本

[复制链接]
梦石
0
星屑
2116
在线时间
950 小时
注册时间
2015-7-16
回帖
692

开拓者

发表于 2016-2-28 18:08:54 | 显示全部楼层 |阅读模式

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

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

×
如題

腳本原出處 https://rpg.blue/thread-369608-1-1.html

有按下A鍵丟棄物品的功能,不過很擔憂有玩家不小心丟掉早期手裡僅有的武器而哭號的狀況發生
誰可以幫忙增加一個特定物品不可以丟棄的功能?
[神性领域扩张:扩张神性领域]
说了等于没说.
梦石
0
星屑
84
在线时间
156 小时
注册时间
2009-8-5
回帖
522
发表于 2016-2-28 21:05:54 | 显示全部楼层
本帖最后由 传说中di 于 2016-2-28 21:20 编辑
  1. #==============================================================================
  2. # +++ VX移植 - VA负重系统改进版 +++
  3. #==============================================================================
  4. # VX版 原作者 By 雪流星
  5. # 蓝本 杂兵天下的VA移植版
  6. # 改进 By:VIPArcher
  7. #  -- 本脚本来自 [url]https://rpg.blue[/url] 使用或转载请保留以上信息。
  8. #
  9. #==============================================================================
  10. # 就是在物品画面的右上角放了一个显示负重的窗口
  11. # 更新了代码,取消的原来的计算每个队员的负重然后累加的模式 2014-12-10
  12. # 增加了商店界面的负重显示     2014-9-3
  13. #==============================================================================
  14. #
  15. # 物品备注<load N> 则该物品占用 N 点负重
  16. # load也可以写成「负重」或「負重」#注:没有“「」”不写的话默认为 Default_Load
  17. # 更改当前负重 current_load(x[,assign])
  18. # 其中 x 为数值可以为负数,assign 为 true 时当前负重直接赋值为x(可省略)
  19. # 例如:current_load(10,true) 当前负重直接赋值为10
  20. # 默认给物品增加一行说明.说明内容是物品的重量.
  21. # 但默认帮助窗口一共只能显示2行内容.
  22. # 因此你在数据库设置武器、护甲说明的时候.
  23. # 如果设置了2行内容.那么这新增加的第3行将无法显示出来.
  24. # 特别地,如果你使用了我的【技能物品说明增强】脚本,请将其置于该脚本以上的位置
  25. #==============================================================================
  26. $VIPArcherScript ||= {};$VIPArcherScript[:load] = 20140919
  27. #==============================================================================
  28. # ★ 设定部分 ★
  29. #==============================================================================
  30. module  VIPArcher end
  31. module  VIPArcher::Load
  32.   Default_Load = 1    #物品的默认负重
  33.   Width = 150         #负重信息窗口宽度
  34.   Load_Name = "负重:" #负重前显示的文字
  35.   Load_Var = 0        #作为队伍负重上限的变量ID,为0禁用变量作为负重上限,变成
  36.                       #累计每个角色的负重能力来计算负重上限
  37.   Load_Eval = "((mhp + mmp) * @level / agi) * [hp_rate,0.5].max"
  38.   # 每个角色的负重计算公式(eval)
  39.   Stop_SW = false       #true 使用 / false 不使用
  40.   # 事件中调用增减道具/武器/防具时,如果会导致超过负重上限,是否执行中断事件处理
  41.   # 推荐不使用,因为新加的功能就有一个是当超过负重时限制角色移动,开启这个
  42.   # 的话这个限制移动就无效了的说·3·

  43.   Movable =  true       #true 使用 / false 不使用
  44.   # 满负重时降低移动速度(不使用时禁止移动连事件都无法启动,只能丢弃/使用物品)

  45.   Move_Speed = 2 # 满负重时的移动速度

  46.   # 负重超过上限时的提示内容
  47.   Message = "\\i[4]负重超过可承受的范围,\n移动将变得\\c[10]十分艰难!\\c[0]
  48. 丢些没用的东西掉吧。"

  49.   # 按X键(A键)是否可以丢弃道具
  50.   # 如果你另外使用了丢弃道具的脚本请关闭
  51.   Lose_SW = true       #true 使用 / false 不使用

  52.   # 是否在帮助窗口内自动添加负重信息
  53.   Help_SW = true       #true 使用 / false 不使用

  54.   # 装备在身上的装备是否算入负重
  55.   Equip_SW = true      #true 计算 / false 不计算
  56.   #         "★★★★★★ 注意 ★★★★★★"
  57.   # 如果你的角色初始装备有占负重并且开启上面的功能,那么你必须
  58.   # 在游戏一开始时为当前负重赋值(自己算到底有多少负重·3·)
  59.   # 当有新队员加入队伍并且也带有负重的装备那么你也需要为当前负重加上对应的重量,
  60.   # 例如:事件脚本运行 current_load(10) 就是加上10的当前负重
  61. end
  62. #==============================================================================
  63. # ☆ 设定结束 ☆
  64. #==============================================================================
  65. class RPG::BaseItem
  66.   include VIPArcher::Load
  67.   #--------------------------------------------------------------------------
  68.   # ● 获取道具的重量
  69.   #--------------------------------------------------------------------------
  70.   def load
  71.     return unless self.is_a?(RPG::Item) || self.is_a?(RPG::EquipItem)
  72.     return $1.to_i if @note =~ /<(?:load|负重|負重)\s*(\d+)>/i
  73.     return Default_Load
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 新增负重帮助内容
  77.   #--------------------------------------------------------------------------
  78.   def description
  79.     if Help_SW && load && load != 0
  80.       return @description + "\n\\}重量:#{load}"
  81.     else
  82.       return @description
  83.     end
  84.   end unless $VIPArcherScript[:help_ex]
  85. end
  86. #==============================================================================
  87. #  显示当前负重信息的窗口
  88. #==============================================================================
  89. class Window_Load < Window_Base
  90.   include VIPArcher::Load
  91.   #--------------------------------------------------------------------------
  92.   # ● 初始化对象
  93.   #--------------------------------------------------------------------------
  94.   def initialize
  95.     super(Graphics.width - window_width, 72, window_width, fitting_height(1))
  96.     refresh
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # ● 获取窗口的宽度
  100.   #--------------------------------------------------------------------------
  101.   def window_width
  102.     Width
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 刷新
  106.   #--------------------------------------------------------------------------
  107.   def refresh
  108.     contents.clear
  109.     contents.font.size - 4
  110.     draw_text(0, 0, window_width - 64, 24,load_name,0)
  111.     draw_text(0, 0, window_width - 24, 24, weight,2)
  112.     @temp_load = $game_party.current_load
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 获取当前负重信息
  116.   #--------------------------------------------------------------------------
  117.   def weight
  118.     "#{$game_party.current_load}/#{$game_party.total_load}"
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 获取负重前显示文字
  122.   #--------------------------------------------------------------------------
  123.   def load_name
  124.     Load_Name
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 更新画面
  128.   #--------------------------------------------------------------------------
  129.   def update
  130.     super
  131.     refresh if @temp_load != $game_party.current_load
  132.   end
  133. end
  134. #-------------------------------------------------------------------------------
  135. class Window_ItemCategory < Window_HorzCommand
  136.   include VIPArcher::Load
  137.   #--------------------------------------------------------------------------
  138.   # ● 获取窗口的宽度
  139.   #--------------------------------------------------------------------------
  140.   def window_width
  141.     scene_item_is? ? Graphics.width - Width : Graphics.width
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 获取列数
  145.   #--------------------------------------------------------------------------
  146.   def col_max
  147.     return scene_item_is? ? 3 : 4
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 判断是否为物品栏场景
  151.   #--------------------------------------------------------------------------
  152.   def scene_item_is?
  153.     return SceneManager.scene_is?(Scene_Item)
  154.   end
  155. end
  156. #==============================================================================
  157. # ■ 物品界面显示负重栏
  158. #==============================================================================
  159. class Scene_Item < Scene_ItemBase
  160.   include VIPArcher::Load
  161.   #--------------------------------------------------------------------------
  162.   # ● 开始处理
  163.   #--------------------------------------------------------------------------
  164.   alias load_start start
  165.   def start
  166.     load_start
  167.     @load_window = Window_Load.new
  168.     @load_window.viewport = @viewport
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 结束处理
  172.   #--------------------------------------------------------------------------
  173.   alias load_terminate terminate
  174.   def terminate
  175.     load_terminate
  176.     @load_window.dispose
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 更新画面
  180.   #--------------------------------------------------------------------------
  181.   alias load_update update
  182.   def update
  183.     #--------------------------------------------------------------------------
  184.     # ★ 按X键(A键)丢弃道具 - 贵重物品无法丢弃 ★修改:VIPArcher
  185.     #--------------------------------------------------------------------------
  186.     if Input.trigger?(Input::X) && Lose_SW
  187.       item = @item_window.item
  188.       if item.is_a?(RPG::Item) && item.key_item?
  189.         Sound.play_buzzer
  190.       else
  191.     if item != nil && item.note.include?("[可丢]")
  192.         Sound.play_cancel
  193.         $game_party.lose_item(item, 1)
  194.         @item_window.refresh
  195.       end unless item == nil
  196.     end
  197.     end
  198.     @load_window.update
  199.     load_update
  200.   end
  201. end
  202. #-------------------------------------------------------------------------------
  203. class Window_ShopNumber < Window_Selectable
  204.   include VIPArcher::Load
  205.   attr_accessor :buy_or_sell                    #买入的标志
  206.   #--------------------------------------------------------------------------
  207.   # ● 刷新
  208.   #--------------------------------------------------------------------------
  209.   alias vip_shopnumber_refresh refresh
  210.   def refresh
  211.     vip_shopnumber_refresh
  212.     draw_current_weight(@item)
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ○ 买卖时重量变化的描绘
  216.   #--------------------------------------------------------------------------
  217.   def draw_current_weight(item)
  218.     current = $game_party.current_load
  219.     weight = current + item.load * @number * (@buy_or_sell ? 1 : -1)
  220.     width = contents_width - 8
  221.     cx = text_size(@currency_unit).width
  222.     change_color(system_color)
  223.     draw_text(4, y + 60, width, line_height, "#{Load_Name}")
  224.     change_color(normal_color)
  225.     wt = "#{weight} / #{$game_party.total_load}"
  226.     draw_text(4, y + 60, width, line_height, wt, 2)
  227.   end
  228. end
  229. #-------------------------------------------------------------------------------
  230. class Window_ShopStatus < Window_Base
  231.   include VIPArcher::Load
  232.   #--------------------------------------------------------------------------
  233.   # ● 刷新
  234.   #--------------------------------------------------------------------------
  235.   alias vip_shopstatus_refresh refresh
  236.   def refresh
  237.     vip_shopstatus_refresh
  238.     draw_weight_occupy(4, 24)
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 绘制持负重信息
  242.   #--------------------------------------------------------------------------
  243.   def draw_weight_occupy(x, y)
  244.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  245.     change_color(system_color)
  246.     draw_text(rect, "#{Load_Name}", 3)
  247.     change_color(normal_color)
  248.     weight = "#{$game_party.current_load}/#{$game_party.total_load}"
  249.     draw_text(rect, weight, 2)
  250.     @temp_load = $game_party.current_load
  251.   end
  252. end
  253. #==============================================================================
  254. # ■ 获取队伍最大负重
  255. #==============================================================================
  256. class Game_Party < Game_Unit
  257.   include VIPArcher::Load
  258.   #--------------------------------------------------------------------------
  259.   # ● 定义实例变量
  260.   #--------------------------------------------------------------------------
  261.   attr_accessor :current_load, :load_trade_item     #负重
  262.   #--------------------------------------------------------------------------
  263.   # ● 初始化对象
  264.   #--------------------------------------------------------------------------
  265.   alias load_initialize initialize
  266.   def initialize
  267.     load_initialize
  268.     total_load
  269.     @current_load = 0
  270.     @total_load = 0
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # ● 获取队伍最大负重
  274.   #--------------------------------------------------------------------------
  275.   def total_load
  276.     return $game_variables[Load_Var] if Load_Var > 0
  277.     all_members.inject(0) {|total,actor| total + actor.load }
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 判断负重是否已满
  281.   #--------------------------------------------------------------------------
  282.   def load_max?
  283.     return false if @current_load == 0
  284.     @current_load >= total_load
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ● 增加/减少物品时计算负重
  288.   #--------------------------------------------------------------------------
  289.   alias load_gain_item gain_item
  290.   def gain_item(item, n, include_equip = false)
  291.     return if item.nil?
  292.     load_gain_item(item, n, include_equip)
  293.     @current_load += item.load * n if !@load_trade_item
  294.   end
  295. end
  296. #-------------------------------------------------------------------------------
  297. class Game_Actor < Game_Battler
  298.   include VIPArcher::Load
  299.   #--------------------------------------------------------------------------
  300.   # ● 装备时不计算负重的增减 * 方法覆盖
  301.   #     new_item : 取出的物品
  302.   #     old_item : 放入的物品
  303.   #--------------------------------------------------------------------------
  304.   def trade_item_with_party(new_item, old_item)
  305.     return false if new_item && !$game_party.has_item?(new_item)
  306.     $game_party.load_trade_item = true if Equip_SW == true
  307.     $game_party.gain_item(old_item, 1)
  308.     $game_party.lose_item(new_item, 1)
  309.     $game_party.load_trade_item = false if Equip_SW == true
  310.     return true
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 获取角色的负重上限
  314.   #--------------------------------------------------------------------------
  315.   def load
  316.     eval(Load_Eval).to_i
  317.   end
  318. end
  319. #==============================================================================
  320. # ■ 增减物品时判断负重
  321. #==============================================================================
  322. class Game_Interpreter
  323.   include VIPArcher::Load
  324.   #--------------------------------------------------------------------------
  325.   # ● 增减道具
  326.   #--------------------------------------------------------------------------
  327.   alias load_command_126 command_126
  328.   def command_126
  329.     n = operate_value(@params[1], @params[2], @params[3])
  330.     return command_115 if check_load(@params[0], 0, n) && Stop_SW
  331.     load_command_126
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 增減武器
  335.   #--------------------------------------------------------------------------
  336.   alias load_command_127 command_127
  337.   def command_127
  338.     n = operate_value(@params[1], @params[2], @params[3])
  339.     return command_115 if check_load(@params[0], 1, n) &&  Stop_SW
  340.     load_command_127
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 增減防具
  344.   #--------------------------------------------------------------------------
  345.   alias load_command_128 command_128
  346.   def command_128
  347.     n = operate_value(@params[1], @params[2], @params[3])
  348.     return command_115 if check_load(@params[0], 2, n) && Stop_SW
  349.     load_command_128
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # ● 增减物品超重时提示
  353.   #--------------------------------------------------------------------------
  354.   def check_load(item_id, type, n)
  355.     case type
  356.     when 0; item = $data_items[item_id]
  357.     when 1; item = $data_weapons[item_id]
  358.     when 2; item = $data_armors[item_id]
  359.     end
  360.     if (((item.load * n) + $game_party.current_load) > $game_party.total_load)
  361.       $game_message.texts.push("#{Message}") if $game_message.visible != true
  362.       $game_message.visible = true
  363.     end
  364.     return (((item.load * n) + $game_party.current_load) > $game_party.total_load)
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● 更改负重
  368.   #--------------------------------------------------------------------------
  369.   def current_load(current_load,assign = false)
  370.     if assign
  371.       $game_party.current_load = current_load
  372.     else
  373.       $game_party.current_load += current_load
  374.     end
  375.   end
  376. end
  377. #==============================================================================
  378. # ★ 满负重时限制行动 ★
  379. #==============================================================================
  380. class Game_Player < Game_Character
  381.   include VIPArcher::Load
  382.   #--------------------------------------------------------------------------
  383.   # ● 判定是否可以移动
  384.   #--------------------------------------------------------------------------
  385.   alias load_movable? movable?
  386.   def movable?
  387.     return false if $game_party.load_max? && !Movable
  388.     load_movable?
  389.   end
  390. end
  391. #==============================================================================
  392. # ★ 满负重时降低移动速度 ★
  393. #==============================================================================
  394. class Game_CharacterBase
  395.   include VIPArcher::Load
  396.   #--------------------------------------------------------------------------
  397.   # ● 获取移动速度(判断是否跑步)
  398.   #--------------------------------------------------------------------------
  399.   alias load_real_move_speed real_move_speed
  400.   def real_move_speed
  401.     return Move_Speed if $game_party.load_max? && Movable
  402.     load_real_move_speed
  403.   end
  404. end
  405. #==============================================================================
  406. # ★ 满负重时限制购买 ★
  407. #==============================================================================
  408. class Window_ShopBuy < Window_Selectable
  409.   #--------------------------------------------------------------------------
  410.   # ● 查询商品是否可买
  411.   #--------------------------------------------------------------------------
  412.   alias load_enable? enable?
  413.   def enable?(item)
  414.     load_enable?(item) && !$game_party.load_max?
  415.   end
  416. end
  417. #==============================================================================
  418. # ★ 根据负重设定可购买的物品数量 ★
  419. #==============================================================================
  420. class Scene_Shop < Scene_MenuBase
  421.   #--------------------------------------------------------------------------
  422.   # ● 指令“买入”
  423.   #--------------------------------------------------------------------------
  424.   alias vip_load_command_buy command_buy
  425.   def command_buy
  426.     vip_load_command_buy
  427.     @number_window.buy_or_sell = true
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 指令“卖出”
  431.   #--------------------------------------------------------------------------
  432.   alias vip_load_command_sell command_sell
  433.   def command_sell
  434.     vip_load_command_sell
  435.     @number_window.buy_or_sell = false
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 获取可以买入的最大值
  439.   #--------------------------------------------------------------------------
  440.   alias load_max_buy max_buy
  441.   def max_buy
  442.     vip = @item.load == 0 ? load_max_buy : ($game_party.total_load -
  443.     $game_party.current_load) / @item.load
  444.     [load_max_buy,vip].min
  445.   end
  446. end
复制代码

在装备备注里打上 [可丢] 的都可以扔掉。如果没有[可丢]就不能丢掉。

点评

話說能否逆向操作? 比如打上 不可丟 ,都要打可丟,道具多了會很頭痛  发表于 2016-2-28 21:41
感謝!  发表于 2016-2-28 21:39

评分

参与人数 2星屑 +15 梦石 +1 收起 理由
丿梁丶小柒 + 1 认可答案
duzine + 15 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部