VX 스크립트

Source Thread: http://rmrk.net/index.php/topic,27955.0.html

  장비에 착용조건을 주는 것입니다.  사용방법은 스크립트의 헤더를 보세요(아이템의 노트창에 장착 조건을 주는 방식입니다).  아이템 장착 조건은 레벨, 파라미터, 다른 장비의 존재, 스킬 중에서 선택할 수 있습니다.

 

#==============================================================================
# ** Item/Equipment/Skill Conditions
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  This script allows you to set stats and/or level requirements for weapons
#  and armor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    Place above Main and below Materials
#
#    To configure this script, you have to place codes in the Notes Field of
#   the respective items. These codes are:
#     
#     LVLR[]           *Actor must be at least this level
#     HPR[]               *Actor must have this much HP
#     MPR[]               *Actor must have this much MP
#     ATKR[]          *Actor must have this much Attack
#     DEFR[]         *Actor must have this much Defense
#     SPIR[]          *Actor must have this much Spirit
#     AGIR[]         *Actor must have this much Agility
#     WPNR[]                   *Weapon must be equipped
#     ARMR[]                    *Armor must be equipped
#     ITMR[, ]                *At least n of item_id in possession
#     ITMR[, ]C               *As above and consumed upon use.
#     PWPNR[, ]  *At least n of weapon_id in possession
#     PWPNR[, ]C *As above and consumed upon use.
#     PARMR[, ]   *At least n of armor_id in possession
#     PARMR[, ]C  *As above and consumed upon use.
#     SKLR[]                    *Skill must be learned
#     STER[]                    *State must be added
#
#    After any of them that make sense, you can also add these restrictions:
#      >= - greater than or equal to - default
#      <= - less than or equal to
#      >  - strictly greater than
#      <  - strictly less than
#      =  - strictly equal to
#
#    You can leave out any or all or none of them and the script will only 
#   restrict the attributes you set
#
#   EXAMPLE:
#     If Club has a Notes Field like this:
#
#       LVLR[6]<
#       ATKR[37]
#       AGIR[27]>
#
#      then an actor could only use that club if he was less than level 6, had 
#     an Attack of at least 37 and an Agility of at least 28.
#==============================================================================
# ** RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes
#    new method - requirements_field
#==============================================================================

class RPG::BaseItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Requirement Field
  #--------------------------------------------------------------------------
  #  This method returns an array of restrictions on using each item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def requirement_field
    r_field = []
    # Dissect Note
    text = self.note.dup
    text.sub! (/lvlr[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    # HP Requirement
    text.sub! (/hpr[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    # MP Requirement
    text.sub! (/mpr[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    # Attack Requirement
    text.sub! (/atkr[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    # Defense Requirement
    text.sub! (/defr[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    # Spirit Requirement
    text.sub! (/spir[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    # Agility Requirement
    text.sub! (/agir[(d+?)](<*>*=*)/i) { '' }
    r_field.push ([$1.to_i, $2.to_s])
    r_field.push ([], [], [], [], [], [], [], [], [], [])
    # Weapon Requirement
    r_field[7].push ($1.to_i) while text.sub! (/wpnr[(d+?)]/i) {''} != nil
    # Armor Requirement
    r_field[8].push ($1.to_i) while text.sub! (/armr[(d+?)]/i) {''} != nil
    # Item Possession Requirement
    while text.sub! (/itmr[(d+),*s*(d*)](C*)(<*>*=*)/i) { '' } != nil
      r_field[9].push ([$1.to_i, [$2.to_i, 1].max, $4.to_s])
      # Consumable items
      r_field[14].push ([$1.to_i, [$2.to_i, 1].max, $4.to_s]) if $3 != ""
    end
    # Weapon Possession Requirement
    while text.sub! (/pwpnr[(d+),*s*(d*)](C*)(<*>*=*)/i) {''} != nil 
      r_field[10].push ([$1.to_i, [$2.to_i, 1].max, $4.to_s]) 
      # Consumable weapons
      r_field[15].push ([$1.to_i, [$2.to_i, 1].max, $4.to_s]) if $3 != nil
    end
    # Armor Possession Requirement
    while text.sub! (/parmr[(d+),*s*(d*)](C*)(<*>*=*)/i) {''} != nil
      r_field[11].push ([$1.to_i, [$2.to_i, 1].max, $4.to_s]) 
      # Consumable Armors
      r_field[16].push ([$1.to_i, [$2.to_i, 1].max, $4.to_s]) if $3 != nil
    end
    # Skill Requirement
    r_field[12].push ($1.to_i) while text.sub! (/sklr[(d+?)]/i) {''} != nil
    # State Requirement
    r_field[13].push ($1.to_i) while text.sub! (/ster[(d+?)]/i) {''} != nil
    return r_field
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check requirements
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def check_reqs (user)
    actor_stats = [user.level, user.maxhp, user.maxmp, user.atk, user.def, user.spi, user.agi]
    reqs = self.requirement_field
    # Stats
    for i in 0...7
      case reqs[i][1]
      when "" # Assume Greater than or Equal to
        return false unless actor_stats[i] >= reqs[i][0]
      else # Other
        begin
          eval ("return false unless actor_stats[i] #{reqs[i][1]} reqs[i][0]")
        rescue
        end
      end
    end
    data = [$data_items, $data_weapons, $data_armors]
    # Weapons and Armor equips
    for i in 7...9
      reqs[i].each { |j| 
        return false unless user.equips.include? (data[i-6][j])
      }
    end
    # Items, Weapons, Armors in possession
    for i in 9...12
      reqs[i].each { |j|
        case j[2]
        when ""
          return false unless $game_party.item_number (data[i-9][j[0]]) >= j[1]
        else
          begin
            eval ("return false unless $game_party.item_number (data[i-9][j[0]]) #{j[2]} j[1]")
          rescue
          end
        end
      }
    end
    # Skills learned
    self.requirement_field[12].each { |i| return false unless user.skill_learn? ($data_skills[i]) }
    # States
    self.requirement_field[13].each { |i| return false unless user.state? (i) }
    return true
  end
end
  
#==============================================================================
# ** Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new method - check_reqs, consume_reagants
#    aliased_methods - equippable?, setup, level_down, maxhp=, maxmp=, atk=, 
#                      def=, spi=, agi=
#    modified super - skill_effect, item_effect, skill_can_use?, item_effective?
#==============================================================================

class Game_Actor < Game_Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup
  #     actor_id : actor ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_equip_required_actor_stp_7ht1 setup
  def setup (actor_id)
    # Run Original Method
    modalg_equip_required_actor_stp_7ht1 (actor_id)
    # Make sure all starting items are allowed to be on the hero
    check_equip_reqs
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Determine if Equippable
  #     item : item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_eqp_reqs_actor_check_equip_5js9 equippable?
  def equippable?(item)
    return false if item == nil
    return modalg_eqp_reqs_actor_check_equip_5js9 (item) & item.check_reqs (self)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Determine Usable Skills
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def skill_can_use? (skill)
    test = super (skill)
    return skill.check_reqs (self) if test
    return test
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Determine if an Item can be Used
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def item_effective?(user, item)
    return super (user, item) if user.is_a? (Game_Enemy)
    return super (user, item) & item.check_reqs (user)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Apply Item Effects
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def item_effect(user, item)
    super (user, item)
    # Consume reagants if consumable
    consume_reagants (item)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Apply Skill Effects
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def skill_effect(user, skill)
    super (user, skill)
    # Consume reagants if consumable
    consume_reagants (skill)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check Equipment Requirements
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def check_equip_reqs
    @checking_equipment = true
    equip_array = equips.dup
    for i in 0...5
      # Unequip everything
      change_equip (i, nil, true)
      test = equippable? (equip_array[i]) 
      change_equip (i, equip_array[i], true)
      # Unequip item for real if requirements not met
      change_equip (i, nil) unless test
    end
    @checking_equipment = false
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Consume Reagants
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def consume_reagants (item)
    unless @skipped || @missed || @evaded
      # Remove items, weapons, and armors
      item.requirement_field[14].each { |i| $game_party.lose_item ($data_items[i[0]], i[1]) }
      item.requirement_field[15].each { |i| $game_party.lose_item ($data_weapons[i[0]], i[1]) }
      item.requirement_field[16].each { |i| $game_party.lose_item ($data_armors[i[0]], i[1]) }
    end
  end
  #--------------------------------------------------------------------------
  # * Make sure requirements still met if stats decrease in any way
  #--------------------------------------------------------------------------
  alias modalg_eqpreqs_lvlup_check_9dn4 level_up
  def level_up
    modalg_eqpreqs_lvlup_check_9dn4
    check_equip_reqs
  end
  
  alias modalg_equip_reqs_changelvl_check_5hy2 level_down
  def level_down
    modalg_equip_reqs_changelvl_check_5hy2
    check_equip_reqs
  end
  
  alias modalg_equip_reqs_changemaxhp_check_h83d maxhp=
  def maxhp=(new_maxhp)
    modalg_equip_reqs_changemaxhp_check_h83d (new_maxhp)
    check_equip_reqs
  end
  
  alias modalg_equip_reqs_changemxmp_check_8fjq maxmp=
  def maxmp=(new_maxmp)
    modalg_equip_reqs_changemxmp_check_8fjq (new_maxmp)
    check_equip_reqs
  end
  
  alias modalg_equip_reqs_change_atk_94nd atk=
  def atk=(new_atk)
    modalg_equip_reqs_change_atk_94nd (new_atk)
    check_equip_reqs
  end
  
  alias modernalg_chck_reqs_def_73ij def=
  def def=(new_def)
    modernalg_chck_reqs_def_73ij (new_def)
    check_equip_reqs
  end
  
  alias modalgebra_reqs_chck_sprit_8dsn spi=
  def spi=(new_spi)
    modalgebra_reqs_chck_sprit_8dsn (new_spi)
    check_equip_reqs
  end
  
  alias modalgebra_requirements_equipment_agi_6hdt agi=
  def agi=(new_agi)
    modalgebra_requirements_equipment_agi_6hdt (new_agi)
    check_equip_reqs
  end
  
  alias ma_chck_eqp_reqs_chnge_equip_7fn change_equip
  def change_equip (equip_type, item, test = false)
    ma_chck_eqp_reqs_chnge_equip_7fn (equip_type, item, test)
    check_equip_reqs if @checking_equipment == nil || !@checking_equipment && !test
  end
  
  alias ma_frgt_skill_check_eqp_reqs_8her forget_skill
  def forget_skill (skill_id)
    ma_frgt_skill_check_eqp_reqs_8her (skill_id)
    check_equip_reqs if @checking_equipment == nil || !@checking_equipment
  end
end

#==============================================================================
# ** Game_Party
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased methods - item_can_use?
#==============================================================================

class Game_Party
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Item Can Use?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_req_itm_party_use_9m43 item_can_use?
  def item_can_use? (item)
    # Run Original Method
    test = modalg_req_itm_party_use_9m43 (item)
    return false unless test
    if $game_temp.in_battle
      return test & item.check_reqs ($scene.active_battler)
    else
      $game_party.members.each { |i| return test if item.check_reqs (i) }
      return false
    end
  end
end

#==============================================================================
# ** Scene_Battle
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    makes public - active_battler
#==============================================================================

class Scene_Battle < Scene_Base
  attr_reader :active_battler
end

#==============================================================================
# ** Scene_Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased method - use_item_nontarget
#==============================================================================

class Scene_Item < Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Item (apply effects to non-ally targets)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_eqp_reqs_consume_regnts_refresh_rn4 use_item_nontarget
  def use_item_nontarget
    # Run Original Method
    modalg_eqp_reqs_consume_regnts_refresh_rn4 
    # Refresh Item Window
    @item_window.refresh
  end
end

 

Comment '3'
  • ?
    크라상 2010.09.18 16:23

     음 요거 대박이네,,..

  • ?
    mymy 2011.01.18 18:36

    오ㅋㅋ 제가 찾던 자료네요 퍼가요ㅎㅎ

  • ?
    웃자 2011.07.30 09:59

    앗사~ 감사합니다 ㅋ~


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
517 기타 이벤트 뿌리기 + 범위지정 8 file 허걱 2009.07.13 2698
516 이동속도의 한계를 없앤다 11 file RPGbooster 2008.10.08 2815
515 이동 및 탈것 이동 기능 파워업 (장애물 등을 피하는 이동방식) 8 file 파노 2014.04.27 1716
514 메뉴 윈도우창 크기 조절 스크립트 0.3 5 아방스 2008.01.30 3038
513 메뉴 윈도우 색변경 스크립트 7 file 비극ㆍ 2010.03.01 2598
512 웨이포인트 9 file RPGbooster 2008.10.08 3415
511 맵/타일 월드맵 스크립트 49 아방스 2008.09.07 6123
510 원경 원경(파노라마) 바꾸기 9 file 허걱 2010.05.28 3369
509 움직이는커서 11 file RPGbooster 2008.10.08 5090
508 기타 요리 시스템을 도입하는 스크립트입니다. 9 file 스페나로츠 2011.08.18 3141
507 온라인 온라인입니다 4 file 알피지GM 2010.03.07 6358
506 저장 오토세이브 VX 5 file 카르와푸딩의아틀리에 2009.10.05 4138
505 전투 오버 드라이브 프로블럼 2 Man... 2008.10.28 2268
504 오버 드라이브 8/24 버젼 20 file RPGbooster 2008.10.11 2904
503 퀘스트 오메가7 퀘스트 스크립트 한글화,사용법,데모게임 직접제작 32 file DH Games 2010.02.14 4578
502 영어 잘하는 사람만 보세요..저도 모르겠음(무슨 스크립트인지) 3 Man... 2008.10.27 1372
501 메시지 여러항목 선택지 ... Scene처리.. 23 file 허걱 2009.02.14 5277
500 기타 여러스크립트(목적은 포인트) 12 file 인생은 힘들다. 2011.08.26 3087
499 전투 에너미를 아이템으로 변화하는 스킬 8 Evangelista 2009.05.27 2850
498 엄청 좋음(DEMO)클릭 하이퍼링크 걸려있음(누가 변혁좀 해 줬으면...) 4 Man... 2008.10.27 1745
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 32 Next
/ 32