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

Project1

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

想做到裝備item要求能力值

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2007-6-28
帖子
84
跳转到指定楼层
1
发表于 2007-7-26 12:16:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
想做到裝備item要求能力值, 但不想在description中加數字, 因我已用了做其他用途, 可有另外的辦法嗎? 事實上我手上有下面的腳本, 也是裝備item要求能力值, 但不能同時要求2種能力要求, 我看了很久也找不到原因, 希望你們能替我找出原因, thanks...(大慨我是覺得是pointer的問題, 但小弟玩rmxp不太久, 因此也不太肯定, 希望有熱心人幫助啊~~)
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆装備制限 - EquipmentRestriction◆
#_/----------------------------------------------------------------------------
#_/  装備品に特殊な装備条件を設定します。
#_/  Institutes special conditions to equip the equipments.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================

module KGC
  # ◆条件配列
  #  ≪[条件, 設定値, 反転], ...≫
  #  配列の添え字が武器/防具IDに対応。
  #  配列の末尾に true を入れると、全条件必須になる。
  #  (true を入れない場合は、いずれかの条件が成り立てば良い)
  #  「反転」を true にすると、条件の「○以上」が「○未満」になる。
  #  (「反転」は省略可)
  #    **** 条件一覧 (○は「設定値」) ****
  #  0 : レベル ○以上
  #  1 : 最大HP ○以上
  #  2 : 最大SP ○以上
  #  3 : 腕力 ○以上
  #  4 : 器用さ ○以上
  #  5 : 素早さ ○以上
  #  6 : 魔力 ○以上
  #  10001~19999 : スイッチID「条件 - 10000」 ON
  #  20001~29999 : 変数ID「条件 - 20000」 ○以上
  ER_WEAPON_RESTRICTION = []  # 武器
  ER_ARMOR_RESTRICTION = []   # 防具
  # <設定例>
  # [武器4]ミスリルソード:レベル 34 以上
  #ER_WEAPON_RESTRICTION[4] = [[0, 34]]
  # [武器32]ミスリルロッド:腕力 300 未満 かつ 魔力 100 以上
  #ER_WEAPON_RESTRICTION[2] = [[1, 10, true], [3, 100], true]
  # [防具20]ミスリルプレート:レベル 16 以上 または 腕力 180 以上
  #ER_ARMOR_RESTRICTION[20] = [[0, 16], [3, 180]]
end

#### ER_WEAPON_RESTRICTION  # Weapon
#### ER_ARMOR_RESTRICTION   # Armor
### Condition array.
#  << [Condition, Value, Reverse], ... >>
#  Each index of the array corresponds to Weapon/Armor ID.
#  If add 'true' at the end of the array, all conditions become indispensable.
#  (If did not added 'true', one of the conditions only has to consist.)
#  If "Reverse" is true, condition "more than" changes into "below".
#  (It is possible to omit "Reverse".)
#    **** Conditon list (X is "Value") ****
#  0 : Level - more than X
#  1 : Max HP - more than X
#  2 : Max SP - more than X
#  3 : Str(Strength) - more than X
#  4 : Dex(Dexterity) - more than X
#  5 : Agi(Agility) - more than X
#  6 : Int(Intelligence) - more than X
#  10001..19999 : Switch ID "'Condition' - 10000" is true
#  20001..29999 : Variable ID "'Condition' - 20000" - more than X

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["EquipmentRestriction"] = true

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 装備可能判定
  #     item : アイテム
  #--------------------------------------------------------------------------
  alias equippable_KGC_EquipmentRestriction? equippable?
  def equippable?(item)
    if (result = equippable_KGC_EquipmentRestriction?(item))
      conditions = nil
      # 条件取得
      if item.is_a?(RPG::Weapon)
        conditions = KGC::ER_WEAPON_RESTRICTION[item.id]
      elsif item.is_a?(RPG::Armor)
        conditions = KGC::ER_ARMOR_RESTRICTION[item.id]
      end
      # 条件判定
      if conditions != nil
        return pass_equipment_restriction?(item, conditions)
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # ● 装備条件通過判定
  #--------------------------------------------------------------------------
  def pass_equipment_restriction?(item, conditions)
    if conditions[-1, 1] == true
      all = conditions.pop
    else
      all = false
    end
    # 条件判定
    conditions.each { |condition|
      result = true
      case condition[0]
      when 0  # レベル
        result = self.level >= condition[1]
      when 1  # MAXHP
        result = self.maxhp >= condition[1]
      when 2  # MAXSP
        result = self.maxsp >= condition[1]
      when 3  # 腕力
        result = self.str >= condition[1]
      when 4  # 器用さ
        result = self.dex >= condition[1]
      when 5  # 素早さ
        result = self.agi >= condition[1]
      when 6  # 魔力
        result = self.int >= condition[1]
      when 10001..19999  # スイッチ
        result = $game_switches[condition[0] - 10000]
      when 20001..29999  # 変数
        result = $game_variables[condition[0] - 20000] >= condition[1]
      end
      # 反転
      if condition[2]
        result = !result
      end
      if all
        # 条件が成り立たない場合は false
        unless result
          return false
        end
      else
        # 条件が成り立つ場合は true
        if result
          return true
        end
      end
    }
    return all
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
#  装備画面で、装備変更の候補となるアイテムの一覧を表示するウィンドウです。
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # 装備可能な武器を追加
    if @equip_type == 0
      (1...$data_weapons.size).each { |i|
        if $game_party.weapon_number(i) > 0 && @actor.equippable?($data_weapons)
          @data.push($data_weapons)
        end
      }
    # 装備可能な防具を追加
    else
      (1...$data_armors.size).each { |i|
        if $game_party.armor_number(i) > 0 && @actor.equippable?($data_armors)
          if $data_armors.kind == @equip_type-1
            @data.push($data_armors)
          end
        end
      }
    end
    # 空白を追加
    @data.push(nil)
    # ビットマップを作成し、全項目を描画
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
end

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2007-6-28
帖子
84
2
 楼主| 发表于 2007-7-26 12:16:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
想做到裝備item要求能力值, 但不想在description中加數字, 因我已用了做其他用途, 可有另外的辦法嗎? 事實上我手上有下面的腳本, 也是裝備item要求能力值, 但不能同時要求2種能力要求, 我看了很久也找不到原因, 希望你們能替我找出原因, thanks...(大慨我是覺得是pointer的問題, 但小弟玩rmxp不太久, 因此也不太肯定, 希望有熱心人幫助啊~~)
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆装備制限 - EquipmentRestriction◆
#_/----------------------------------------------------------------------------
#_/  装備品に特殊な装備条件を設定します。
#_/  Institutes special conditions to equip the equipments.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================

module KGC
  # ◆条件配列
  #  ≪[条件, 設定値, 反転], ...≫
  #  配列の添え字が武器/防具IDに対応。
  #  配列の末尾に true を入れると、全条件必須になる。
  #  (true を入れない場合は、いずれかの条件が成り立てば良い)
  #  「反転」を true にすると、条件の「○以上」が「○未満」になる。
  #  (「反転」は省略可)
  #    **** 条件一覧 (○は「設定値」) ****
  #  0 : レベル ○以上
  #  1 : 最大HP ○以上
  #  2 : 最大SP ○以上
  #  3 : 腕力 ○以上
  #  4 : 器用さ ○以上
  #  5 : 素早さ ○以上
  #  6 : 魔力 ○以上
  #  10001~19999 : スイッチID「条件 - 10000」 ON
  #  20001~29999 : 変数ID「条件 - 20000」 ○以上
  ER_WEAPON_RESTRICTION = []  # 武器
  ER_ARMOR_RESTRICTION = []   # 防具
  # <設定例>
  # [武器4]ミスリルソード:レベル 34 以上
  #ER_WEAPON_RESTRICTION[4] = [[0, 34]]
  # [武器32]ミスリルロッド:腕力 300 未満 かつ 魔力 100 以上
  #ER_WEAPON_RESTRICTION[2] = [[1, 10, true], [3, 100], true]
  # [防具20]ミスリルプレート:レベル 16 以上 または 腕力 180 以上
  #ER_ARMOR_RESTRICTION[20] = [[0, 16], [3, 180]]
end

#### ER_WEAPON_RESTRICTION  # Weapon
#### ER_ARMOR_RESTRICTION   # Armor
### Condition array.
#  << [Condition, Value, Reverse], ... >>
#  Each index of the array corresponds to Weapon/Armor ID.
#  If add 'true' at the end of the array, all conditions become indispensable.
#  (If did not added 'true', one of the conditions only has to consist.)
#  If "Reverse" is true, condition "more than" changes into "below".
#  (It is possible to omit "Reverse".)
#    **** Conditon list (X is "Value") ****
#  0 : Level - more than X
#  1 : Max HP - more than X
#  2 : Max SP - more than X
#  3 : Str(Strength) - more than X
#  4 : Dex(Dexterity) - more than X
#  5 : Agi(Agility) - more than X
#  6 : Int(Intelligence) - more than X
#  10001..19999 : Switch ID "'Condition' - 10000" is true
#  20001..29999 : Variable ID "'Condition' - 20000" - more than X

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["EquipmentRestriction"] = true

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 装備可能判定
  #     item : アイテム
  #--------------------------------------------------------------------------
  alias equippable_KGC_EquipmentRestriction? equippable?
  def equippable?(item)
    if (result = equippable_KGC_EquipmentRestriction?(item))
      conditions = nil
      # 条件取得
      if item.is_a?(RPG::Weapon)
        conditions = KGC::ER_WEAPON_RESTRICTION[item.id]
      elsif item.is_a?(RPG::Armor)
        conditions = KGC::ER_ARMOR_RESTRICTION[item.id]
      end
      # 条件判定
      if conditions != nil
        return pass_equipment_restriction?(item, conditions)
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # ● 装備条件通過判定
  #--------------------------------------------------------------------------
  def pass_equipment_restriction?(item, conditions)
    if conditions[-1, 1] == true
      all = conditions.pop
    else
      all = false
    end
    # 条件判定
    conditions.each { |condition|
      result = true
      case condition[0]
      when 0  # レベル
        result = self.level >= condition[1]
      when 1  # MAXHP
        result = self.maxhp >= condition[1]
      when 2  # MAXSP
        result = self.maxsp >= condition[1]
      when 3  # 腕力
        result = self.str >= condition[1]
      when 4  # 器用さ
        result = self.dex >= condition[1]
      when 5  # 素早さ
        result = self.agi >= condition[1]
      when 6  # 魔力
        result = self.int >= condition[1]
      when 10001..19999  # スイッチ
        result = $game_switches[condition[0] - 10000]
      when 20001..29999  # 変数
        result = $game_variables[condition[0] - 20000] >= condition[1]
      end
      # 反転
      if condition[2]
        result = !result
      end
      if all
        # 条件が成り立たない場合は false
        unless result
          return false
        end
      else
        # 条件が成り立つ場合は true
        if result
          return true
        end
      end
    }
    return all
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
#  装備画面で、装備変更の候補となるアイテムの一覧を表示するウィンドウです。
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # 装備可能な武器を追加
    if @equip_type == 0
      (1...$data_weapons.size).each { |i|
        if $game_party.weapon_number(i) > 0 && @actor.equippable?($data_weapons)
          @data.push($data_weapons)
        end
      }
    # 装備可能な防具を追加
    else
      (1...$data_armors.size).each { |i|
        if $game_party.armor_number(i) > 0 && @actor.equippable?($data_armors)
          if $data_armors.kind == @equip_type-1
            @data.push($data_armors)
          end
        end
      }
    end
    # 空白を追加
    @data.push(nil)
    # ビットマップを作成し、全項目を描画
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
end

Lv2.观梦者

梦石
0
星屑
270
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

3
发表于 2007-7-26 14:23:51 | 只看该作者
那就在名字里加
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
7 小时
注册时间
2007-6-28
帖子
84
4
 楼主| 发表于 2007-7-26 17:15:25 | 只看该作者
也用了.....{/pz}
以下引用亿万星辰于2007-7-26 6:23:51的发言:

那就在名字里加

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-7-2 00:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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