질문과 답변

Extra Form


이 스크립트인데요 (백호님이 올려주신..)
7번 스킬을 배워야 8번 스킬 구매가 활성화되고
8번 스킬을 배워야 9번 스킬 구매가 활성화되고
이런 식으로 수정이 가능한지 부탁드리겠습니다 ㅎ..


Comment '4'
  • profile
    습작 2012.06.26 23:03

    0.

     

      단도직입적으로 해당 스크립트를 어떻게 수정해야 하는지 알려드리겠습니다.(코드를 보기 쉽게 설명은 파랑색으로 적습니다.)


    module RPG

      class Skill

        def price

          case id

          #==========================

          # CONFIG PRICE

          #==========================

          # use 

          # when skill_id then return price

          when 1 then return 50

          when 57 then return 75

          end

          return 10

        end

        def llevel

          case id

          #==========================

          # CONFIG LEVEL

          #==========================

          # use

          # when skill_id then return level

          when 57 then return 2

          end

          return 1

        end

        def precedence

          case id

          #==========================

          # 먼저 알고 있어야 하는 스킬 리스트

          #==========================

          # 사용법

          # when 배울 스킬 아이디 then return 미리 배워야 하는 스킬 아이디

          when 2 then return 1 # id 2번 스킬을 배우기 위해서는 id 1번 스킬을 알아야 합니다요. 고갱님.

          when 9 then return 8 # 고갱님 아직도 8번 안배우고 오셨는감요?

          end

          return nil

        end

      end

      class Class

        def learnskills

          case id

          #==========================

          # CONFIG CLASS SKILLS

          #==========================

          # use

          # when class_id then return [skill id's here]

          when 1 then return [57, 58, 59, 60]

          when 2 then return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 81]

          when 7 then return [69, 70, 71, 72, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]

          when 8 then return [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56]

          end

          return []

        end

      #==========================

      # END CONFIG

      #==========================

      end

    end


      우선 먼저 배워야 하는 스킬 데이터 베이스를 추가해 봅시다. 붉은 색 문자 부분은 제가 추가한 스크립트 코드이며, 녹색 부분은 그 사용법을 안내하고 있는 주석내용입니다.(주석은 필요없다면 추가하지 않으셔도 되는 부분입니다.)


    class Window_SkillStatus2 < Window_Selectable

      def initialize

        super(368, 128, 272, 352)

        self.contents = Bitmap.new(width - 32, height - 32)

        refresh

        self.z = 200

        self.active = false

        self.index = -1

      end

      def refresh

        self.contents.clear

        @item_max = $game_party.actors.size

        for i in 0...$game_party.actors.size

          x = 64

          y = i * 80

          actor = $game_party.actors[i]

          classs = $data_classes[$game_actors[actor.id].class_id]

          draw_actor_graphic(actor, x - 40, y + 60)

          draw_actor_name(actor, x - 13, y + 10)

          if actor.skill_learn?($thing.id)

            self.contents.font.color = crisis_color

            $text = "Aquired"

          elsif GameGuy::UseClasses

            if classs.learnskills.include?($thing.id) && $thing.llevel <= actor.level

              if $thing.precedence == nil or actor.skill_learn?($thing.precedence)

                self.contents.font.color = normal_color

                $text = "Can Learn"

              else

                self.contents.font.color = disabled_color

                $text = "너님" + $data_skills[$thing.precedence].name + " 먼저 배워야 함요."

              end

            elsif classs.learnskills.include?($thing.id) && $thing.llevel > actor.level

              self.contents.font.color = disabled_color

              $text = "Can Learn At Level " + $thing.llevel.to_s

            else

              self.contents.font.color = disabled_color

              $text = "Can't Learn"

            end

          else

            if actor.level >= $thing.llevel

              if $thing.precedence == nil or actor.skill_learn?($thing.precedence)

                self.contents.font.color = normal_color

                $text = "Can Learn"

              else

                self.contents.font.color = disabled_color

                $text = "너님" + $data_skills[$thing.precedence].name + " 먼저 배워야 함요."

              end

            else

              self.contents.font.color = disabled_color

              $text = "Can Learn At Level " + $thing.llevel.to_s

            end

          end

          self.contents.draw_text(x - 13, y + 40, 200, 32, $text)

        end

      end

      def update_cursor_rect

        if @index < 0

          self.cursor_rect.empty

        else

          self.cursor_rect.set(0, @index * 80, self.width - 32, 80)

        end

      end

    end


      그리고 이번에는 상태창에서 나타낼 문구 부분을 수정해 봅시다. 마찬가지로 붉은 부분이 제가 추가로 삽입한 코드 입니다. 두군데나 수정해 줘야 하는 까닭은 이놈의 스크립트가 직업별 스킬 사용판정을 쓸경우와 안쓸경우로 나눠서 판정하기 때문입니다.


    class SkillShop

      def initialize(skills)

        @skills = skills

      end

      def main

        @command = Window_SkillCommand.new

        @help_window = Window_Help.new

        @skillbuy = Window_SkillBuy.new(@skills)

        @skillbuy.active = false

        @skillbuy.help_window = @help_window

        $thing = @skillbuy.skill

        @status = Window_SkillStatus2.new

        #@status.visible = false

        @gold = Window_Gold.new

        @gold.x = 480

        @gold.y = 64

        

        Graphics.transition

        loop do

          Graphics.update

          Input.update

          update

          if $scene != self

            break

          end

        end

        Graphics.freeze

        @gold.dispose

        @skillbuy.dispose

        @help_window.dispose

        @command.dispose

        @status.dispose

      end

      def update

        @gold.update

        @status.update

        @gold.refresh

        @command.update

        @skillbuy.update

        @help_window.update

        $thing = @skillbuy.skill

        @status.refresh

        if @command.active

          update_command

          return

        end

        

        if @status.active

          update_status

          return

        end

        

        if @skillbuy.active

          update_buy

          return

        end

      end

      

      def update_buy

        if Input.trigger?(Input::B)

          $game_system.se_play($data_system.cancel_se)

          @skillbuy.active = false

          @command.active = true

          return

        end

        if Input.trigger?(Input::C)

          $game_system.se_play($data_system.decision_se)

          @skillbuy.active = false

          @status.active = true

          @status.visible = true

          @status.index = 0 if @status.index == -1

        end

      end

      

      def update_command

        if Input.trigger?(Input::B)

          $game_system.se_play($data_system.cancel_se)

          $scene = Scene_Map.new

          return

        end

        if Input.trigger?(Input::C)

          $game_system.se_play($data_system.decision_se)

          case @command.index

          when 0

            @command.active = false

            @skillbuy.active = true

          when 1

            $game_system.se_play($data_system.cancel_se)

            $scene = Scene_Map.new

          end

          return

        end

      end

      

      def update_status

        if Input.trigger?(Input::B)

          @status.active = false

          @skillbuy.active = true

          return

        end

        if Input.trigger?(Input::C)

          price = @skillbuy.skill.price

          @actort = $game_party.actors[@status.index]

          enabled = (price <= $game_party.gold)

          

          if enabled

            if @actort.skill_learn?(@skillbuy.skill.id)

              $game_system.se_play($data_system.buzzer_se)

              return

            end

            if GameGuy::UseClasses

              if $data_classes[@actort.class_id].learnskills.include?(@skillbuy.skill.id) && @actort.level >= @skillbuy.skill.llevel && (@skillbuy.skill.precedence == nil or @actort.skill_learn?(@skillbuy.skill.precedence))

                @actort.learn_skill(@skillbuy.skill.id)

                $game_party.lose_gold(@skillbuy.skill.price)

                $game_system.se_play($data_system.decision_se)

                @skillbuy.active = true

                @status.active = false

                @status.refresh

                return

              else

                $game_system.se_play($data_system.buzzer_se)

                return

              end

            else

              if @actort.level >= @skillbuy.skill.llevel && (@skillbuy.skill.precedence == nil or @actort.skill_learn?(@skillbuy.skill.precedence))

                @actort.learn_skill(@skillbuy.skill.id)

                $game_party.lose_gold(@skillbuy.skill.price)

                $game_system.se_play($data_system.decision_se)

                @skillbuy.active = true

                @status.active = false

                @status.refresh

              else

                $game_system.se_play($data_system.buzzer_se)

                return

              end

              return

            end

            

          else

            $game_system.se_play($data_system.buzzer_se)

            return

          end

        end

      end

     

    end


      마지막으로 실제로 스킬 구입씬에서 너님은 안됨! 하고 부저소리를 울려줄 곳입니다. 마찬가지로 붉은 색이 제가 추가한 코드이므로 잘 적어줍시다.


      여기까지 완료하셨다면 해당 스크립트는 아직 때가 되지 않은 불민한 플레이어의 캐릭터들에게 가차없는 징벌을 내릴 것입니다. 그럼 완성된 게임으로 게임 자료실에서 뵙길 바랍니다. 좋은 게임 제작 활동하세요.^^


  • profile
    습작 2012.06.26 23:06

    1.


      덧붙여 질문의 제목을 [Skill Shop 스크립트 선행스킬 판정 추가] 정도로 수정해 주신다면 다른 질문자들께서 동일한 질문에 대해서 보다 쉽게 검색하고 찾을 수 있을거라 생각합니다.

     


  • profile
    습작 2012.06.26 23:14

    2.

     

      다시보니 잘 못 작성된 코드가 몇군데 있어서 수정했습니다. 0번 댓글에 그 내용이 업데이트 되었으니 확인하시고 다시 수정하시면 됩니다.



  • ?
    모모아이 2012.06.27 18:11
    제목 수정했구요 ㅠㅠ 감사합니다 ㅠ

List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12448
RMVXA 대화창 불투명도 조절 1 수녀갓 2017.02.13 177
RMMV 게임 시작시 창 크기를 자동으로 늘리는 방법은 없을까요? 최진홍 2017.02.12 98
RMVX 메뉴 캐릭터의 직업란을 안보이게 하고싶습니다. 6 file 가온하제 2017.02.12 170
RMXP 포켓몬스터 처럼 이벤트 시점에 엑터가 있으면 이벤트 발동 1 퀼트 2017.02.12 209
RMVXA 안녕하세요 고수님들 저 좀 도와 주세요 2 유한소수 2017.02.12 94
RMXP 조사 중복 1 퀼트 2017.02.11 75
RMXP 이동 경로 오류(?) 1 퀼트 2017.02.09 88
RMMV 사이드뷰 전투시 액터1의 위치 변경할수 있는 방법이 있을까요? 2 붕붕붕 2017.02.08 281
RMXP 자동 실행 오류 3 퀼트 2017.02.07 78
RMVXA 그림표시 질문... 1 file 쑤수 2017.02.07 241
RMXP 그래픽 변수 1 퀼트 2017.02.05 79
RMVXA 그림번호가,,뭐죠 3 vGONv 2017.02.05 120
RMVXA 이벤트 하는데 오류가 뜨네요,,, 2 file vGONv 2017.02.04 86
RMVXA 텍스트박스 옆에 캐릭터 나오는 법,,,알려주세요 1 file vGONv 2017.02.04 217
RMVXA 턴제 전투에서 병렬이벤트 적용 기폭 2017.02.03 73
RMMV 캐릭터의 TP 를 변수로 지정하고 싶은데 방법을 모르겠어요 PP 2017.02.02 79
RMVXA 횡스크롤 형식의 게임을 어떻게 구현해야할지 질문드립니다. 2 황태 2017.02.02 982
RMMV 플러그인을 만들어보고 싶은데 혹시 open API 가 있을까요? 1 무르무르 2017.02.01 118
RMMV Khas Advanced Graphics관련 질문 7 file nuclearjam 2017.02.01 159
라이선스 기타 알피지 메이커의 다른 툴 끼리도 저작권 공유가 되나요? 1 PP 2017.01.30 198
Board Pagination Prev 1 ... 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 ... 516 Next
/ 516