XP 마법/기술 반사 스크립트 알려주셔요

by takehim906 posted Feb 05, 2006
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆마법 반사 - KGC_SkillReflection◆
#_/----------------------------------------------------------------------------
#_/  마법 반사 기능을 추가합니다.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ 커스터마이즈 항목 ★
#==============================================================================

module KGC
  # ◆반사시 애니메이션 ID
  REFLECTION_ANIM_ID = 101
  # ◆반사 스테이트명
  REFLECTION_STATE_NAME = "리후레크"
end

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

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

if $game_special_states == nil
  $game_special_states = {}
  $data_states = load_data("Data/States.rxdata")
end
# 마법 반사용 스테이트 ID취득
state = $data_states.compact.find { |s| s.name == KGC::REFLECTION_STATE_NAME }
$game_special_states["reflection"] = (state != nil ? state.id : 0)

#==============================================================================
# ■ Game_Battler (분할 정의 2)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 반사 스테이트 판정
  #     skill : 처리 대상의 스킬
  #--------------------------------------------------------------------------
  def reflection?(skill)
    # 반사 스테이트 부가, 한편 스킬이 마법의 경우
    if @states.include?($game_special_states["reflection"]) &&
        skill.atk_f == 0 && skill.int_f > 0
      return true
    end
    return false
  end
end

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

#==============================================================================
# ■ Game_Battler (분할 정의 3)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 스킬의 효과 적용
  #     user  : 스킬의 사용자 (버틀러)
  #     skill : 스킬
  #--------------------------------------------------------------------------
  alias skill_effect_KGC_SkillReflection skill_effect
  def skill_effect(user, skill)
    # 반사할 수 있는 경우는 돌아온다
    return false if user != self && self.reflection?(skill)

    # 원래의 처리를 실행
    return skill_effect_KGC_SkillReflection(user, skill)
  end
end

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

#==============================================================================
# ■ Scene_Battle (분할 정의 4)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 스킬 액션 결과 작성
  #--------------------------------------------------------------------------
  alias make_skill_action_result_KGC_SkillReflection make_skill_action_result
  def make_skill_action_result
    # 원래의 처리를 실행
    make_skill_action_result_KGC_SkillReflection

    # 리후레크 발동 플래그를 오프
    @skill_reflected = false
    # 원래의 발동자 데미지를 초기화
    user_damage = 0
    for target in @target_battlers
      # 리후레크 발동 판정
      if @skill != nil && target != @active_battler && target.reflection?(@skill)
        # 리후레크 발동 플래그를 온
        @skill_reflected = true
        # 발동자에게 뒤집는다
        @active_battler.skill_effect(@active_battler, @skill)
        # 데미지가 양쪽 모두 수치의 경우
        if user_damage.is_a?(Numeric) && @active_battler.damage.is_a?(Numeric)
          # 데미지를 가산
          user_damage += @active_battler.damage
        else
          # 그대로 설정
          user_damage = @active_battler.damage
        end
      end
    end
    # 최종적인 데미지를 적용
    @active_battler.damage = user_damage if @skill_reflected
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신 (메인 국면 스텝 4 : 대상측 애니메이션)
  #--------------------------------------------------------------------------
  alias update_phase4_step4_KGC_SkillReflection update_phase4_step4
  def update_phase4_step4
    # 원래의 처리를 실행
    update_phase4_step4_KGC_SkillReflection

    # 리후레크가 발동했을 경우
    if @active_battler.current_action.kind == 1 && @skill_reflected
      # 대상측 애니메이션
      for target in @target_battlers
        # 대상의 리후레크가 발동했을 경우
        if target.reflection?(@skill)
          # 발동자에게 애니메이션을 돌려준다
          @active_battler.animation_id = @animation2_id
          @active_battler.animation_hit = (target.damage != "Miss")
          # 타겟트궸후레크 발동 애니메이션을 설정
          target.animation_id = KGC::REFLECTION_ANIM_ID
          target.animation_hit = true
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 프레임 갱신 (메인 국면 스텝 5 : 데미지 표시)
  #--------------------------------------------------------------------------
  alias update_phase4_step5_KGC_SkillReflection update_phase4_step5
  def update_phase4_step5
    # 원래의 처리를 실행
    update_phase4_step5_KGC_SkillReflection

    # 리후레크가 발동했을 경우
    if @skill_reflected
      # 발동자도 데미지 표시
      if @active_battler.damage != nil
        @active_battler.damage_pop = true
      end
      @skill_reflected = false
    end
  end
end















설명부분 이에요 ^^

다음에, 「리후레크」라고 하는 이름의 스테이트를 만듭니다.
(스테이트명은 커스터마이즈 항목으로 변경 가능)
이 스테이트는[저항하지 않는][배틀 종료시에 해제]를 체크해 둡니다.
그 외의 설정은 기호에 맞추어 주세요.
스킬의[공격력 F]를 1으로 하면, 반사 불가능한 마법을 표현할 수 있습니다.

Articles

1 2 3 4 5 6 7 8 9 10