조회 수 268 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
#==============================================================================
# ■ Game_Battler (분할 정의 3)
#------------------------------------------------------------------------------
#  버틀러를 취급하는 클래스입니다. 이 클래스는 Game_Actor 클래스와 Game_Enemy 곳간
# 스의 슈퍼 클래스로서 사용됩니다.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 스킬의 사용 가능 판정
  #     skill_id : 스킬 ID
  #--------------------------------------------------------------------------
  def skill_can_use? (skill_id)
    # SP 가 부족한 경우는 사용 불가
    if $data_skills[skill_id]. sp_cost > self.sp
      return false
    end
    # 침묵 상태의 경우, 물리 스킬 이외는 사용 불가
    if $data_skills[skill_id]. atk_f == 0 and self.restriction == 1
      return false
    end
    # 사용 가능시를 취득
    occasion = $data_skills[skill_id]. occasion
    # 전투중의 경우
    if $game_temp.in_battle
      # [상시] 또는 [배틀만] 이라면 사용가능
      return (occasion == 0 or occasion == 1)
    # 전투중이 아닌 경우
    else
      # [상시] 또는 [메뉴만] 이라면 사용가능
      return (occasion == 0 or occasion == 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● 통상 공격의 효과 적용
  #     attacker : 공격자 (버틀러)
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # 위기 플래그를 클리어
    self.critical = false
    # 제일 명중 판정
    hit_result = (rand(100) < attacker.hit)
    # 명중의 경우
    if hit_result == true
      # 기본 데미지를 계산
      atk = [attacker.atk - self.pdef / 2, 0]. max
      self.damage = atk * (20 + attacker.str) / 20
      # 속성 수정
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # 데미지의 부호가 정의 경우
      if self.damage > 0
        # 위기 수정
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # 방어 수정
        if self.guarding?
          self.damage /= 2
        end
      end
      # 분산
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1]. max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # 제2 명중 판정
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ?  100 : 100 - eva
      hit = self.cant_evade?  ?  100 : hit
      hit_result = (rand(100) < hit)
    end
    # 명중의 경우
    if hit_result == true
      # 스테이트 충격 해제
      remove_states_shock
      # HP 로부터 데미지를 감산
      self.hp -= self.damage
      # 스테이트 변화
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # 미스의 경우
    else
      # 데미지에 "Miss" 를 설정
      self.damage = "Miss"
      # 위기 플래그를 클리어
      self.critical = false
    end
    # 메소드 종료
    return true
  end
  #--------------------------------------------------------------------------
  # ● 스킬의 효과 적용
  #     user  : 스킬의 사용자 (버틀러)
  #     skill : 스킬
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # 위기 플래그를 클리어
    self.critical = false
    # 스킬의 효과 범위가 HP 1 이상의 아군으로, 자신의 HP 가 0,
    # 또는 스킬의 효과 범위가 HP 0 의 아군으로, 자신의 HP 가 1 이상의 경우
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # 메소드 종료
      return false
    end
    # 유효 플래그를 클리어
    effective = false
    # 코먼 이벤트 ID 가 유효의 경우는 유효 플래그를 세트
    effective |= skill.common_event_id > 0
    # 제일 명중 판정
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # 불확실한 스킬의 경우는 유효 플래그를 세트
    effective |= hit < 100
    # 명중의 경우
    if hit_result == true
      # 위력을 계산
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0]. max
      end
      # 배율을 계산
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # 기본 데미지를 계산
      self.damage = power * rate / 20
      # 속성 수정
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # 데미지의 부호가 정의 경우
      if self.damage > 0
        # 방어 수정
        if self.guarding?
          self.damage /= 2
        end
      end
      # 분산
      if self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1]. max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # 제2 명중 판정
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ?  100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade?  ?  100 : hit
      hit_result = (rand(100) < hit)
      # 불확실한 스킬의 경우는 유효 플래그를 세트
      effective |= hit < 100
    end
    # 명중의 경우
    if hit_result == true
      # 위력 0 이외의 물리 공격의 경우
      if skill.power != 0 and skill.atk_f > 0
        # 스테이트 충격 해제
        remove_states_shock
        # 유효 플래그를 세트
        effective = true
      end
      # HP 로부터 데미지를 감산
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # 스테이트 변화
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # 위력이 0 의 경우
      if skill.power == 0
        # 데미지에 공문자열을 설정
        self.damage = ""
        # 스테이트에 변화가 없는 경우
        unless @state_changed
          # 데미지에 "Miss" 를 설정
          self.damage = "Miss"
        end
      end
    # 미스의 경우
    else
      # 데미지에 "Miss" 를 설정
      self.damage = "Miss"
    end
    # 전투중이 아닌 경우
    unless $game_temp.in_battle
      # 데미지에 nil 를 설정
      self.damage = nil
    end
    # 메소드 종료
    return effective
  end
  #--------------------------------------------------------------------------
  # ● 아이템의 효과 적용
  #     item : 아이템
  #--------------------------------------------------------------------------
  def item_effect(item)
    # 위기 플래그를 클리어
    self.critical = false
    # 아이템의 효과 범위가 HP 1 이상의 아군으로, 자신의 HP 가 0,
    # 또는 아이템의 효과 범위가 HP 0 의 아군으로, 자신의 HP 가 1 이상의 경우
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # 메소드 종료
      return false
    end
    # 유효 플래그를 클리어
    effective = false
    # 코먼 이벤트 ID 가 유효의 경우는 유효 플래그를 세트
    effective |= item.common_event_id > 0
    # 회복량을 계산
    recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
    recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
    # 속성 수정
    recover_hp *= elements_correct(item.element_set)
    recover_hp /= 100
    # 회복량의 부호가 부의 경우
    if recover_hp < 0
      # 방어 수정
      recover_hp /= 2
    end
    # HP 회복량의 부호를 반전해, 데미지의 값으로 설정
    self.damage = -recover_hp
    # HP 및 SP 를 회복
    last_hp = self.hp
    last_sp = self.sp
    self.hp += recover_hp
    self.sp += recover_sp
    effective |= self.hp != last_hp
    effective |= self.sp != last_sp
    # 스테이트 변화
    @state_changed = false
    effective |= states_plus(item.plus_state_set)
    effective |= states_minus(item.minus_state_set)
    # 파라미터 상승치가 유효의 경우
    if item.parameter_type > 0 and item.parameter_points != 0
      # 파라미터로 분기
      case item.parameter_type
      when 1  # MaxHP
        @maxhp_plus += item.parameter_points
      when 2  # MaxSP
        @maxsp_plus += item.parameter_points
      when 3  # 완력
        @str_plus += item.parameter_points
      when 4  # 손재주가 있음
        @dex_plus += item.parameter_points
      when 5  # 민첩함
        @agi_plus += item.parameter_points
      when 6  # 마력
        @int_plus += item.parameter_points
      end
      # 유효 플래그를 세트
      effective = true
    end
    # HP 회복율과 회복량이 0 의 경우
    if item.recover_hp_rate == 0 and item.recover_hp == 0
      # 데미지에 공문자열을 설정
      self.damage = ""
      # SP 회복율과 회복량이 0, 파라미터 상승치가 무효의 경우
      if item.recover_sp_rate == 0 and item.recover_sp == 0 and
         (item.parameter_type == 0 or item.parameter_points == 0)
        # 스테이트에 변화가 없는 경우
        unless @state_changed
          # 데미지에 "Miss" 를 설정
          self.damage = "Miss"
        end
      end
    end
    # 전투중이 아닌 경우
    unless $game_temp.in_battle
      # 데미지에 nil 를 설정
      self.damage = nil
    end
    # 메소드 종료
    return effective
  end
  #--------------------------------------------------------------------------
  # ● 슬립 데미지의 효과 적용
  #--------------------------------------------------------------------------
  def slip_damage_effect
    # 데미지를 설정
    self.damage = self.maxhp / 10
    # 분산
    if self.damage.abs > 0
      amp = [self.damage.abs * 15 / 100, 1]. max
      self.damage += rand(amp+1) + rand(amp+1) - amp
    end
    # HP 로부터 데미지를 감산
    self.hp -= self.damage
    # 메소드 종료
    return true
  end
  #--------------------------------------------------------------------------
  # ● 속성 수정의 계산
  #     element_set : 속성
  #--------------------------------------------------------------------------
  def elements_correct(element_set)
    # 무속성의 경우
    if element_set == []
      # 100 을 돌려준다
      return 100
    end
    # 주어진 속성 중(안)에서 가장 약한 것을 돌려준다
    # ※메소드 element_rate 는, 이 클래스로부터 계승되는 Game_Actor
    #   및 Game_Enemy 클래스에서 정의된다
    weakest = -100
    for i in element_set
      weakest = [weakest, self.element_rate(i)]. max
    end
    return weakest
  end
end


이상은 Game_battler 3 의 스크립트 내용입니다.

제가 루비언어의 계산방식과 문법 그리고 여러가지 방식 (예를들어 Self.ddf 에서 . 이 하는 역할이 뭔지..) 을 정확히 이해하지 못해서요..

위의 스크립트가 해석이 불가능하다는 이야기지요.

위 스크립트를 잘 해석하면.. 데미지의 계산방식을 알 수 있을것도 같은데..

어디를 고치면 뭐가 어떻게 되는지, 계산방식을 이리저리 바꾸면 데미지가 이렇게 계산될수도 있다던지.. 어디를 고치면 프로그램이 오류를 먹는다던지.. 잘 아시는분 제발 설명해주세요.. ㅠ_ㅠ

아시는 분 계시길 바라며..
?

  1. 쯔꾸르 mv 게임을 apk 파일로 변환했는데...

    Date2023.01.14 By박하맛 Views1332
    Read More
  2. 쯔꾸르 젖소이야기 결혼 방법좀 알려주세요...

    Date2021.12.20 By백지씨 Views2627
    Read More
  3. apk포팅 승인 어케 하나요?

    Date2021.11.29 Bygame메이커xp Views1258
    Read More
  4. Yanfly님의 Action Sequence Pack 질문드립니다

    Date2021.07.15 ByNeuromancer Views1543
    Read More
  5. 싸게 MV 를 먼저? 아니면 돈을 더 들어서라도 MZ?

    Date2021.07.06 ByXatra Views1754
    Read More
  6. RMMV - 스탯창과 대화창 변견 관련 질문입니다. (초보입니다 도움좀 주세요 ㅜㅜ)

    Date2021.01.22 Byscribble Views1554
    Read More
  7. 아오오니를 하는 사람인데요 질문 두가지가 있어요

    Date2021.01.16 By오니개무서워 Views1636
    Read More
  8. 재밌는게임

    Date2020.12.07 Byland_tnt Views1456
    Read More
  9. c언어 질문

    Date2020.11.10 By세종기항19 Views1685
    Read More
  10. 코딩 질문

    Date2020.11.08 By세종기항19 Views1541
    Read More
  11. 혹시나 물어보는데

    Date2020.11.07 By드래곤규 Views1402
    Read More
  12. 오픈보 게임 더블드래곤 리로디드 얼티네이트에 대해 궁금

    Date2020.09.09 By이부닝 Views1225
    Read More
  13. 상태이상 확률 결정

    Date2020.09.02 By스트레이보우 Views1007
    Read More
  14. 다음 인디사이드 제작대회는 언제쯤 열릴까요?

    Date2020.05.23 ByWOONAALAA Views963
    Read More
  15. xp로 제작된 어플 실행자체가 안된다는 분이 있습니다.(제생각엔 apk로 변환하는 과정에서 버전자체가 낮은 것 같습니다)

    Date2020.05.04 By라엔 Views1419
    Read More
  16. apk 포팅하는데 게임 이름이 필요합니다 뜨는데

    Date2020.05.03 Bykashu Views1350
    Read More
  17. 쯔꾸르VX Ace렉먹음 도와주세요...

    Date2020.03.22 By랖랖 Views1780
    Read More
  18. 안녕하세요

    Date2020.02.14 By청월령 Views834
    Read More
  19. 포팅 중 '게임 이름이 필요합니다' 오류

    Date2020.02.11 By아이비스 Views818
    Read More
  20. RPGMV 거리 추적

    Date2020.01.19 By정욱 Views934
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 442 Next
/ 442


[개인정보취급방침] | [이용약관] | [제휴문의] | [후원창구] | [인디사이드연혁]

Copyright © 1999 - 2016 INdiSide.com/(주)씨엘쓰리디 All Rights Reserved.
인디사이드 운영자 : 천무(이지선) | kernys(김원배) | 사신지(김병국)