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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2111
在线时间
950 小时
注册时间
2015-7-16
帖子
767

开拓者

跳转到指定楼层
1
发表于 2016-2-28 18:08:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如題

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

有按下A鍵丟棄物品的功能,不過很擔憂有玩家不小心丟掉早期手裡僅有的武器而哭號的狀況發生
誰可以幫忙增加一個特定物品不可以丟棄的功能?
[神性领域扩张:扩张神性领域]
说了等于没说.

Lv1.梦旅人

梦石
0
星屑
84
在线时间
156 小时
注册时间
2009-8-5
帖子
533
2
发表于 2016-2-28 21:05:54 | 只看该作者
本帖最后由 传说中di 于 2016-2-28 21:20 编辑

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

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

点评

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

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-2-23 14:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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