스킬

스킬 필요 조건(번역)

by 훈덕 posted Feb 03, 2009
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄





###########################
# Requirements for Skills #
##############################################################################
# 버전 1.1                                                               
# 제작자: Queex                                                             
# 저작권: 비상업적 일반 창작자
# 필요 스크립트: TagNote 2.0 이상  (이 스크립트보다 위쪽에 위치하도록!)                                               
# 번역: 훈덕
##############################################################################
# 스킬의 사용에 필요 조건이 생깁니다.
# 이것을 활용하여
# 기술을 사용하면 불화살이 소모되게 한다거나
# HP가 낮을 때만 발동되는 초필살기 등을 만들 수 있습니다.
#
# 필요 조건은 스킬의 메모 항목에 표기하면됩니다. 
# 각 종류별로 하나의 태그만 인식됩니다.                  
#            
#                                                                           
# 무기의 메모 항목에 표기하는 태그:                   
# <weapon_type xxx>                                                         
#                                                                          
# 아이템에 표기 가능한 태그:                                           
# <include_battle_test> - 이 아이템을 테스트 전투에서 사용가능하게 해줌 
#                                                                          
# 스킬에 표기 가능한 태그:                                     
# <weapon_type xxx> - 해당 종류의 무기로만 스킬 사용 가능   
# <item_present id> - 파티가 해당 id의 아이템을 소유하고 있어야 스킬 사용 가능 
# <item_consume id n> - 스킬 사용시 id 아이템을 n 개 소비               
# <item_consume id> - 스킬 사용시 id 아이템을 1 개 소비               
# <hp_percent_exceed per> - HP가 비율 per 이상        
# <hp_percent_below per> - HP가 비율 per 미만 
# <mp_percent_exceed per> - MP가 비율 per 이상                                                     
# <mp_percent_exceed per true> - MP를 비율 per 만큼 소비
# <mp_percent_below per> - MP가 비율 per 미만             
# <free_hand> - 적어도 한 손이 빈손이어야 함                
# <dual_weapon> - 이도류 사용                      
# <two_handed_weapon> - 양손무기 사용      
#   
#
# 예를 들어:
# <item_present 3>
# <item_consumed 4 2>
# <weapon_type bow>
#
# 위의 스킬을 사용하려면 id 3 아이템이 필요하고
# 사용할때 id 4 아이템을 2개씩 소비하며
# bow 타입으로 설정된 (메모란에 <weapon_type bow> 라고 입력한) 무기를 장비해야합니다.
#
#
#
#                                                                      
# Note:                                                                     
# This script also includes the function hands_free which returns the       
# number of free hands for a Game_Actor.                                    
#                                                                           
# Version History:                                                          
# 0.4 - test release                                                        
# 0.5 - can specify some item to include in battle test                     
# 1.0 - Bugfix and update to TagNote 2.0                                    
# 1.1 - Fix regressions                                                     
##############################################################################

class Game_Actor < Game_Battler
 
  include TAGNOTE

  def hands_free
    if weapons[0]==nil
      if @armor1_id[0]==0
        return 2
      elsif weapons.length==2
        if weapons[1].two_handed
          return 0
        else
          return 1
        end
      else
        return 1
      end
    elsif weapons[0].two_handed or @armor1_id!=0
      return 0
    else
      return 1
    end
  end

  alias skill_req_skill_can_use? skill_can_use?
  def skill_can_use?(skill)
   
    if skill.id != 0
      skill_note=$data_skills[skill.id].note
      #Check for weapon type
      skill_needs = get_tag(skill_note,"weapon_type") #weapon type string
      if skill_needs != nil
        if two_swords_style
          if @weapon_id!=0 and @armor1_id!=0
            return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs) or has_tag_value?($data_weapons[@armor1_id].note,"weapon_type",skill_needs)
          elsif @weapon_id!=0
            return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs)
          elsif @armor1_id!=0
            return false unless has_tag_value?($data_weapons[@armor1_id].note,"weapon_type",skill_needs)
          else
            return false
          end
        else
          return false unless @weapon_id!=0
          return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs)
        end
      end
     
      #Check for item presence
      skill_needs = get_tag(skill_note,"item_present") #item id
      if skill_needs != nil
        return false unless $game_party.has_item?($data_items[skill_needs.to_i],true)
      end
     
      #Check for item consumption
      skill_needs = get_tag(skill_note,"item_consume") #item id
      if skill_needs !=nil
        skill_needs_num = get_additional_tag(skill_note,"item_consume",2) #number
        if skill_needs_num == nil
          skill_needs_num = 1
        end
        return false unless $game_party.item_number($data_items[skill_needs.to_i])>=skill_needs_num.to_i
      end
     
      #Check for HP exceeds
      skill_needs = get_tag(skill_note,"hp_percent_exceed") #percent
      if skill_needs !=nil
        return false unless (100.0 * @hp/maxhp)>=skill_needs.to_f
      end
     
      #Check for HP below
      skill_needs = get_tag(skill_note,"hp_percent_below") #percent
      if skill_needs != nil
        return false unless (100.0 * @hp/maxhp)<skill_needs.to_f
      end
     
      #Check for MP exceeds
      skill_needs = get_tag(skill_note,"mp_percent_exceed") #percent
      if skill_needs != nil
        return false unless (100.0 * @mp/maxmp)>=skill_needs.to_f
      end
     
      #Check for MP below
      skill_needs = get_tag(skill_note,"mp_percent_below") #percent
      if skill_needs != nil
        return false unless (100.0* @mp/maxmp)<skill_needs.to_f
      end
     
      #Check for free hand
      skill_needs = has_tag?(skill_note,"free_hand") #boolean
      if skill_needs
        return false unless hands_free>=1
      end
     
      #Check for dual weapons
      skill_needs = has_tag?(skill_note,"dual_weapon") #boolean
      if skill_needs
        return false unless two_swords_style
        return false unless weapons[0]!=nil and weapons[1]!=nil
      end
     
      #Check for two-handed weapon
      skill_needs = has_tag?(skill_note,"two_handed_weapon") #boolean
      if skill_needs
        if two_swords_style
          return false unless ( weapons[0]!= nil and weapons[0].two_handed) or (weapons[1] != nil and weapons[1].two_handed)
        else
          return false unless ( weapons[0]!= nil and weapons[0].two_handed)
        end
      end
     
      return skill_req_skill_can_use?(skill)
    end
  end
 
 
  def calc_mp_cost(skill)
    base_cost=skill.mp_cost
   
    mp_prop=get_tag(skill.note,"mp_percent_exceed")
    if mp_prop!=nil
      mp_lose=get_additional_tag_value(skill.note,"mp_percent_exceed",2)
      if mp_lose.eql?("true")
        base_cost=(mp_prop.to_f/100.0 * maxmp).to_i
      end
    end
   
    if half_mp_cost
      return base_cost / 2
    else
      return base_cost
    end
  end
 
end

class Scene_Battle < Scene_Base
 
  include TAGNOTE
#--------------------------------------------------------------------------
# * Execute Battle Action: Skill
#--------------------------------------------------------------------------
  alias skill_req_execute_action_skill execute_action_skill
  def execute_action_skill
    skill_req_execute_action_skill
    skill = @active_battler.action.skill
   
    #consume items required
    skill_needs = get_tag(skill.note,"item_consume")
    if skill_needs != nil
      num_items = get_additional_tag(skill.note,"item_consume",2)
      if num_items==nil
        num_items=1
      end
      $game_party.lose_item($data_items[skill_needs.to_i],num_items.to_i,true)
    end
  end
end

class Game_Party < Game_Unit
 
  include TAGNOTE
 
  alias skill_req_setup_battle_test_members setup_battle_test_members
  def setup_battle_test_members
    skill_req_setup_battle_test_members
    for i in 1...$data_items.size
      if has_tag?($data_items[i].note,"include_battle_test")
        @items[i] = 99
      end
    end
  end
end