| 
 
| 赞 | 2 |  
| VIP | 333 |  
| 好人卡 | 91 |  
| 积分 | 2 |  
| 经验 | 55775 |  
| 最后登录 | 2017-7-18 |  
| 在线时间 | 2070 小时 |  
 Lv1.梦旅人 Mr.Gandum 
	梦石0 星屑226 在线时间2070 小时注册时间2007-1-31帖子3039 
 | 
| Brushbrother 发表于 2014-2-12 15:07 ![]() 简单但是怎么做。。。我过一会发一个详细一点的帖子
 简单的做了一个脚本来让装备/拿下武器防具的时候让一个可以指定的变量增减。
 在装备的备注栏内输入其中n是指定的变量ID,N是增减的数值并且要在前面输入加号或者减号。
 然后变量ID也会根据装备/拿下武器防具的角色ID变化。
 如1号角色装备上了备注栏上写着<Var10+5>的武器,那么第11号变量(指定的10加上角色ID1)就会多5。
 拿下的时候会减去指定的数值。
 以下是脚本
 复制代码class RPG::BaseItem
  def get_addvar
    temp = []
    @note.each_line do |line|
      case line
      when /\<Var(\d+)([+-]\d+)\>/i
        temp.push([$1.to_i,$2.to_i])
      end
    end
    return temp
  end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  管理角色的类。
#   本类在 Game_Actors 类 ($game_actors) 的内部使用。
#   具体使用请查看 Game_Party 类 ($game_party) 。
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 更换装备
  #     slot_id : 装备栏 ID
  #     item    : 武器/护甲(为 nil 时装备解除)
  #--------------------------------------------------------------------------
  alias equipchangevar_change_equip change_equip
  def change_equip(slot_id, item)
    preitem = @equips[slot_id].object
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    equipchangevar_change_equip(slot_id,item)
    if item && !item.get_addvar.empty?
      item.get_addvar.each do |arr|
        $game_variables[arr[0]+@actor_id] += arr[1]
      end
    end
    if preitem && !preitem.get_addvar.empty?
      preitem.get_addvar.each do |arr|
        $game_variables[arr[0]+@actor_id] -= arr[1]
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 强制更换装备
  #     slot_id : 装备栏 ID
  #     item    : 武器/护甲(为 nil 时装备解除)
  #--------------------------------------------------------------------------
  alias equipchangevar_force_change_equip force_change_equip
  def force_change_equip(slot_id, item)
    preitem = @equips[slot_id].object
    equipchangevar_force_change_equip(slot_id,item)
    if item && !item.get_addvar.empty?
      item.get_addvar.each do |arr|
        $game_variables[arr[0]+@actor_id] += arr[1]
      end
    end
    if preitem && !preitem.get_addvar.empty?
      preitem.get_addvar.each do |arr|
        $game_variables[arr[0]+@actor_id] -= arr[1]
      end
    end
  end
end
 | 
 |