查看: 2380|回复: 2

[已经过期] 这个装备负重系统如何学习某技能后增加最大负重?

[复制链接]
梦石
0
星屑
710
在线时间
663 小时
注册时间
2012-10-21
回帖
251
发表于 2014-9-8 10:14:30 | 显示全部楼层 |阅读模式

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

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

×
RT,这个负重系统默认的是使用技能或者物品来提升目标的最大负重,但是问题来了,如果不断使用提升负重的技能,那么负重上限会无限增加,那么负重限制就没有意义了,大神能不能帮修改下,改成学习某个技能后提升最大负重上限?这样我把这个技能设置为不能使用,于是负重上限就有限的提升而不是无限增加了。


[pre lang="ruby" line="1"]#==============================================================================
# Crystal Engine - Equipment Weight
#------------------------------------------------------------------------------
# Current Version: 1.00
#==============================================================================
$imported ||= {}
$imported["CE-EquipmentWeight"] = true
=begin
This script allows you to set up a weight system for your equipment. This system
sets all equipable items to have a weight. When an actor's equipment is too
heavy the play cannot exit out of the equip scene (or cycle to another actor).
-------------------------------------------------------------------------------
Notetags:
Actor Notes
Class Notes
<weight limit: x> # Sets the class's weight limit to x (actor limit take priority)
Skill Notes
<change weight limit: +x> # Add x to the target's weight limit
<change weight limit: -x> # Subtract x to the target's weight limit
Item Notes
<change weight limit: +x> # Add x to the target's weight limit
<change weight limit: -x> # Subtract x to the target's weight limit
<weight: x> # Sets the weight of the item to x (only if using CE - Item Accessories)
Weapon Notes
<weight: x> # Sets the weight of the weapon to x
Armor Notes
<weight: x> # Sets the weight of the armor to x
-------------------------------------------------------------------------------
Script Calls:
change_weight_limit(actor_id, amount) # Modify the specified actor's weight limit
# by the amount specified
=end
module CRYSTAL
  module EQUIP
   
    #--------------------------------------------------------------------------
    # * Default Weight Limit for Actors
    #--------------------------------------------------------------------------
    DEFAULT_WEIGHT_LIMIT = 20
   
    #--------------------------------------------------------------------------
    # * Default Weight for Equipment
    #--------------------------------------------------------------------------
    DEFAULT_WEIGHT = 5
   
  end
end
#==============================================================================
# Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad,
# so edit at your own risk.
#==============================================================================
#==============================================================================
# ** RPG::Actor
#------------------------------------------------------------------------------
#  The data class for actors.
#==============================================================================

class RPG::Actor < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Weight Limit
  #--------------------------------------------------------------------------
  def weight_limit
    @note =~ /<WEIGHT LIMIT: (\d+)>/i ? $1.to_i : nil
  end
end
#==============================================================================
# ** RPG::Class
#------------------------------------------------------------------------------
#  The data class for classes.
#==============================================================================

class RPG::Class < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Weight Limit
  #--------------------------------------------------------------------------
  def weight_limit
    @note =~ /<WEIGHT LIMIT: (\d+)>/i ? $1.to_i : CRYSTAL::EQUIP::DEFAULT_WEIGHT_LIMIT
  end
end
#==============================================================================
# ** RPG::UsableItem
#------------------------------------------------------------------------------
#  A superclass of weapons and armor.
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Weight
  #--------------------------------------------------------------------------
  def weight_mod
    @note =~ /<CHANGE WEIGHT LIMIT: ([\+\-]\d+)>/i ? $1.to_i : 0
  end
end
#==============================================================================
# ** RPG::Item
#------------------------------------------------------------------------------
#  A superclass of weapons and armor.
#==============================================================================

class RPG::Item < RPG::UsableItem
  #--------------------------------------------------------------------------
  # * Weight
  #--------------------------------------------------------------------------
  def weight
    @note =~ /<WEIGHT: (\d+)>/i ? $1.to_i : CRYSTAL::EQUIP::DEFAULT_WEIGHT
  end
end
#==============================================================================
# ** RPG::EquipItem
#------------------------------------------------------------------------------
#  A superclass of weapons and armor.
#==============================================================================

class RPG::EquipItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Weight
  #--------------------------------------------------------------------------
  def weight
    @note =~ /<WEIGHT: (\d+)>/i ? $1.to_i : CRYSTAL::EQUIP::DEFAULT_WEIGHT
  end
end
#==============================================================================
# ** SceneManager
#------------------------------------------------------------------------------
#  This module manages scene transitions. For example, it can handle
# hierarchical structures such as calling the item screen from the main menu
# or returning from the item screen to the main menu.
#==============================================================================

module SceneManager
  #--------------------------------------------------------------------------
  # * Force Recall
  #--------------------------------------------------------------------------
  def self.force_recall(scene_class)
    @Scene = scene_class
  end
end # SceneManager
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Test Skill/Item Application
  #    Used to determine, for example, if a character is already fully healed
  #   and so cannot recover anymore.
  #--------------------------------------------------------------------------
  alias item_test_ce_equipment_weight item_test
  def item_test(user, item)
    return true if actor? && item.weight_mod != 0
    return item_test_ce_equipment_weight(user, item)
  end
  #--------------------------------------------------------------------------
  # * Apply Effect of Skill/Item
  #--------------------------------------------------------------------------
  alias item_apply_ce_equipment_weight item_apply
  def item_apply(user, item)
    item_apply_ce_equipment_weight(user, item)
    return if enemy?
    @weight_mod += item.weight_mod
    if available_weight < 0
      if $game_party.in_battle
        Graphics.freeze
        SceneManager.scene.info_viewport.visible = false
        SceneManager.scene.log_window.visible = false
        hide_extra_gauges if $imported["YEA-BattleEngine"]
        SceneManager.snapshot_for_background
        $game_party.menu_actor = self
        old_scene = SceneManager.scene
        SceneManager.call(Scene_Equip)
        SceneManager.scene.main
        SceneManager.force_recall(old_scene)
        show_extra_gauges if $imported["YEA-BattleEngine"]
        SceneManager.scene.info_viewport.visible = true
        SceneManager.scene.log_window.visible = true
        SceneManager.scene.status_window.refresh
        SceneManager.scene.perform_transition
      else
        SceneManager.scene.instance_variables.each do |varname|
          ivar = SceneManager.scene.instance_variable_get(varname)
          ivar.visible = false if ivar.is_a?(Window)
        end
        $game_party.menu_actor = self
        old_scene = SceneManager.scene
        SceneManager.call(Scene_Equip)
        SceneManager.scene.main
        SceneManager.force_recall(old_scene)
        SceneManager.scene.instance_variables.each do |varname|
          ivar = SceneManager.scene.instance_variable_get(varname)
          ivar.visible = true if ivar.is_a?(Window)
        end
        SceneManager.scene.perform_transition
      end
    end
  end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :weight_mod               # Equipment Weight Modifier
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  alias setup_ce_equipment_weight setup
  def setup(actor_id)
    @weight_mod = 0
    setup_ce_equipment_weight(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Base Weight Limit
  #--------------------------------------------------------------------------
  def base_weight_limit
    actor.weight_limit ? actor.weight_limit : self.class.weight_limit
  end
  #--------------------------------------------------------------------------
  # * Max Weight Limit
  #--------------------------------------------------------------------------
  def max_weight_limit
    base_weight_limit + @weight_mod
  end
  #--------------------------------------------------------------------------
  # * Combined Weight of All Equipment
  #--------------------------------------------------------------------------
  def equipment_weight
    equips.compact.inject(0) {|r, item| r += item.weight }
  end
  #--------------------------------------------------------------------------
  # * Weight Availible for Equipment
  #--------------------------------------------------------------------------
  def available_weight
    max_weight_limit - equipment_weight
  end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Change Weight Limit for Actor
  #--------------------------------------------------------------------------
  def change_weight_limit(actor_id, amount)
    $game_actors[actor_id].weight_mod += amount
    if $game_actors[actor_id].available_weight < 0
      if $game_party.in_battle
        Graphics.freeze
        SceneManager.scene.info_viewport.visible = false
        SceneManager.scene.log_window.visible = false
        hide_extra_gauges if $imported["YEA-BattleEngine"]
        SceneManager.snapshot_for_background
        $game_party.menu_actor = $game_actors[actor_id]
        old_scene = SceneManager.scene
        SceneManager.call(Scene_Equip)
        SceneManager.scene.main
        SceneManager.force_recall(old_scene)
        show_extra_gauges if $imported["YEA-BattleEngine"]
        SceneManager.scene.info_viewport.visible = true
        SceneManager.scene.log_window.visible = true
        SceneManager.scene.status_window.refresh
        SceneManager.scene.perform_transition
      else
        $game_party.menu_actor = self
        old_scene = SceneManager.scene
        SceneManager.call(Scene_Equip)
        SceneManager.scene.main
        SceneManager.force_recall(old_scene)
        SceneManager.scene.perform_transition
      end
    end
  end
end
#==============================================================================
# ** Window_EquipCommand
#------------------------------------------------------------------------------
#  This window is for selecting commands (change equipment/ultimate equipment
# etc.) on the skill screen.
#==============================================================================

class Window_EquipCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :actor                    # The Actor Displayed
  #--------------------------------------------------------------------------
  # * Get Activation State of Cancel Processing
  #--------------------------------------------------------------------------
  def can_cancel?
    return false if @actor && @actor.available_weight < 0
    return true
  end
  #--------------------------------------------------------------------------
  # * Processing When Cancel Button Is Pressed
  #--------------------------------------------------------------------------
  alias process_cancel_ce_equipment_weight process_cancel
  def process_cancel
    if can_cancel?
      process_cancel_ce_equipment_weight
    else
      Sound.play_buzzer
    end
  end
  #--------------------------------------------------------------------------
  # * Processing When L Button (Page Up) Is Pressed
  #--------------------------------------------------------------------------
  alias process_pageup_ce_equipment_weight process_pageup
  def process_pageup
    if can_cancel?
      process_pageup_ce_equipment_weight
    else
      Sound.play_buzzer
    end
  end
  #--------------------------------------------------------------------------
  # * Processing When R Button (Page Down) Is Pressed
  #--------------------------------------------------------------------------
  alias process_pagedown_ce_equipment_weight process_pagedown
  def process_pagedown
    if can_cancel?
      process_pagedown_ce_equipment_weight
    else
      Sound.play_buzzer
    end
  end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs the equipment screen processing.
#==============================================================================

class Scene_Equip < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias create_command_window_ce_equipment_weight create_command_window
  def create_command_window
    create_command_window_ce_equipment_weight
    @command_window.actor = @actor
  end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :info_viewport
  attr_accessor :status_window
  attr_accessor :log_window
end
if $imported["YEA-AceEquipEngine"]
  #==============================================================================
  # ** Window_EquipSlot
  #------------------------------------------------------------------------------
  #  This window displays items the actor is currently equipped with on the
  # equipment screen.
  #==============================================================================

  class Window_EquipSlot < Window_Selectable
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_reader   :weight_window            # Status window
    #--------------------------------------------------------------------------
    # * Set Status Window
    #--------------------------------------------------------------------------
    def weight_window=(weight_window)
      @weight_window = weight_window
      call_update_help
    end
    #--------------------------------------------------------------------------
    # * Update Help Text
    #--------------------------------------------------------------------------
    alias update_help_ce_equipment_weight update_help
    def update_help
      update_help_ce_equipment_weight
      @weight_window.set_temp_actor(nil) if @weight_window
    end
  end
  #==============================================================================
  # ** Window_EquipItem
  #------------------------------------------------------------------------------
  #  This window displays choices when opting to change equipment on the
  # equipment screen.
  #==============================================================================

  class Window_EquipItem < Window_ItemList
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_reader   :weight_window            # Status window
    #--------------------------------------------------------------------------
    # * Set Status Window
    #--------------------------------------------------------------------------
    def weight_window=(weight_window)
      @weight_window = weight_window
      call_update_help
    end
    #--------------------------------------------------------------------------
    # * Update Help Text
    #--------------------------------------------------------------------------
    alias update_help_ce_equipment_weight update_help
    def update_help
      update_help_ce_equipment_weight
      if @actor && @weight_window
        temp_actor = Marshal.load(Marshal.dump(@actor))
        temp_actor.force_change_equip(@slot_id, item)
        @weight_window.set_temp_actor(temp_actor)
      end
    end
  end
  #==============================================================================
  # ** Window_EquipWeight
  #------------------------------------------------------------------------------
  #  This window displays the weight changes for an actor in the equipscreen
  #==============================================================================

  class Window_EquipWeight < Window_Base
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_reader   :actor                    # The Actor Displayed
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize(width, actor)
      super(416, 0, width, fitting_height(1))
      @actor = actor
      refresh
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
      contents.clear
      draw_weight
    end
    #--------------------------------------------------------------------------
    # * Set Actor
    #--------------------------------------------------------------------------
    def actor=(actor)
      return if @actor == actor
      @actor = actor
      refresh
    end
    #--------------------------------------------------------------------------
    # * Set Temporary Actor After Equipment Change
    #--------------------------------------------------------------------------
    def set_temp_actor(temp_actor)
      return if @temp_actor == temp_actor
      @temp_actor = temp_actor
      refresh
    end
    #--------------------------------------------------------------------------
    # * Draw Weight
    #--------------------------------------------------------------------------
    def draw_weight
      draw_text(0, 0, 112, line_height, "Weight")
      change_color(normal_color)
      pos = 0
      draw_text(112, 0, text_size("(").width + 5, line_height, "(")
      pos += text_size("(").width
      if @temp_actor
        change_color(param_change_color(@temp_actor.available_weight - actor.available_weight))
        n = @temp_actor.available_weight.to_s
        draw_text(112 + pos, 0, text_size(n).width + 5, line_height, n)
        pos += text_size(n).width
      else
        change_color(param_change_color(0 - 1)) if actor.available_weight < 0
        n = actor.available_weight.to_s
        draw_text(112 + pos, 0, text_size(n).width + 5, line_height, n)
        pos += text_size(n).width
      end
      change_color(normal_color)
      max = "/#{actor.max_weight_limit})"
      draw_text(112 + pos, 0, width, line_height, max)
    end
  end
  #==============================================================================
  # ** Scene_Equip
  #------------------------------------------------------------------------------
  #  This class performs the equipment screen processing.
  #==============================================================================

  class Scene_Equip < Scene_MenuBase
    #--------------------------------------------------------------------------
    # * Create Slot Window
    #--------------------------------------------------------------------------
    alias create_slot_window_ce_equipment_weight create_slot_window
    def create_slot_window
      create_slot_window_ce_equipment_weight
      @weight_window = Window_EquipWeight.new(@slot_window.width, @actor)
      @slot_window.height -= @weight_window.height
      @slot_window.refresh
      @weight_window.y = @slot_window.y + @slot_window.height
      @slot_window.weight_window = @weight_window
    end
    #--------------------------------------------------------------------------
    # * Create Item Window
    #--------------------------------------------------------------------------
    alias create_item_window_ce_equipment_weight create_item_window
    def create_item_window
      create_item_window_ce_equipment_weight
      @item_window.weight_window = @weight_window
    end
    #--------------------------------------------------------------------------
    # * [Ultimate Equipment] Command
    #--------------------------------------------------------------------------
    alias command_optimize_ce_equipment_weight command_optimize
    def command_optimize
      command_optimize_ce_equipment_weight
      @weight_window.refresh
    end
    #--------------------------------------------------------------------------
    # * [Remove All] Command
    #--------------------------------------------------------------------------
    alias command_clear_ce_equipment_weight command_clear
    def command_clear
      command_clear_ce_equipment_weight
      @weight_window.refresh
    end
  end
else
  #==============================================================================
  # ** Window_EquipStatus
  #------------------------------------------------------------------------------
  #  This window displays actor parameter changes on the equipment screen.
  #==============================================================================

  class Window_EquipStatus < Window_Base
    #--------------------------------------------------------------------------
    # * Draw Name
    #--------------------------------------------------------------------------
    alias draw_actor_name_ce_equipment_weight draw_actor_name
    def draw_actor_name(actor, x, y, width = 112)
      draw_actor_name_ce_equipment_weight(actor, x, y)
      change_color(normal_color)
      pos = 0
      draw_text(x + width, y, text_size("(").width + 5, line_height, "(")
      pos += text_size("(").width
      if @temp_actor
        change_color(param_change_color(@temp_actor.available_weight - actor.available_weight))
        n = @temp_actor.available_weight.to_s
        draw_text(x + width + pos, y, text_size(n).width + 5, line_height, n)
        pos += text_size(n).width
      else
        change_color(param_change_color(0 - 1)) if actor.available_weight < 0
        n = actor.available_weight.to_s
        draw_text(x + width + pos, y, text_size(n).width + 5, line_height, n)
        pos += text_size(n).width
      end
      change_color(normal_color)
      max = "/#{actor.max_weight_limit})"
      draw_text(x + width + pos, y, width, line_height, max)
    end
  end
end
#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

点评

……并行处理一个条件判断行不行?  发表于 2014-9-8 10:17

闇吼者の災悪眷族

梦石
0
星屑
1366
在线时间
2881 小时
注册时间
2014-7-29
回帖
6408
发表于 2014-9-8 10:45:14 | 显示全部楼层
本帖最后由 三途亚梦 于 2014-9-8 10:47 编辑

我有知道另外一个脚本可以帮你达到效果

它的作用是这样的,给所有技能增加一个使用次数限制,默认是无限制。
这个限制的次数的回复由其它任意技能、物品、变量等等进行管理

你可以为增加负重的技能设置1个上限,用这个脚本提供的方法在必要的时候给这个技能恢复使用次数,再继续增加负重。

PS:因为这个脚本需要翻译的地方比较多一些,如果你要用我再翻译给你搬过来。
回复

使用道具 举报

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-9-8 12:43:09 来自手机 | 显示全部楼层
重定义 Game_Actor#base_weight_limit

点评

那个方法的返回值就是  发表于 2014-9-8 16:51
我找不到哪个是最大负重的变量,你可以帮看下嘛?然后,那个变量+5 if actor.skill_learn(id)?这样?  发表于 2014-9-8 16:34
加上技能造成的影响  发表于 2014-9-8 14:45
请问要怎么定义?  发表于 2014-9-8 14:39
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部