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

Project1

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

[VIPArcher] 【队伍负重】图书馆脚本改进版

[复制链接]

无限の剣制

梦石
0
星屑
9956
在线时间
5019 小时
注册时间
2013-2-28
帖子
5030

开拓者贵宾

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

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

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

x
本帖最后由 VIPArcher 于 2014-12-10 11:52 编辑

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

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

GMT+8, 2024-4-28 03:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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