질문과 답변

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 12393
RMXP 턴알피지를 만드는데 방법 좀 알려주셨으면.. 2 아미상 2012.07.01 1298
RMVX 캐릭터가 움직이지 않는 이유 (VX)통행설정 문제 아님 2 file 황금시계 2012.07.01 1939
기타 RGSS2 스크립트 작성을 배우기 위한 초석이 되는 언어는 무엇입니까? 8 지나가는떡꼬치 2012.06.30 1614
RMVXA 가입인사 및 질문입니다. ^^;; [서로 교체하는 두 캐릭터의 경험치 공유 방법] 3 건설로봇 2012.06.29 1428
RMVX 장비착용시키는법 5 file 카릴리스 2012.06.29 1645
RMVX 애니메이션 한 프레임당 초가 몇인지 알고싶습니다. 4 톰소여동생 2012.06.29 7182
기타 루아 책 추천 좀 해주세요~ 1 TheAquila 2012.06.29 1772
RMXP 아이템 습득에 관해서 간단히 질문좀 할게요. 2 file 아우엔 2012.06.29 1352
RMVX RPG 만들기 VX 지도 범위 최대 정수가 500인데 다 표현할 수 있는 방법이 있나요? 4 지나가는떡꼬치 2012.06.29 1758
GM 정말로 막연한 질문이지만 제발 답변해주세요 ㅠ 1 깜이 2012.06.29 1778
RMVXA 같은 아이템을 다른 가격에 판매하기 4 세븐체크 2012.06.28 1304
기타 Crypt-EX 로 압축된 파일들을 푸는 방법좀.. 2 c1856 2012.06.28 3119
RMXP 스크립트에서의 변수값...? 2 Krrrr7 2012.06.27 1419
RMXP rpg만들기xp 맵이름 표시하는방법 2 오매갓 2012.06.27 1768
RMVXA 장비확장 질문 1 세계의질서 2012.06.27 1152
RMVX 드래곤 퀘스트 IV 지도에 대한 질문입니다. 3 지나가는떡꼬치 2012.06.27 1215
RMVXA Database Limit Breaker 3 세계의질서 2012.06.27 1149
RMXP Skill Shop 스크립트 선행스킬 판정 추가 방법 4 모모아이 2012.06.26 997
RMVX 저주받은 갑옷 구현 2 FNS키리토 2012.06.26 2657
RMXP 드래곤 퀘스트 IV 시스템 스크립트 구현을 원합니다. 3 지나가는떡꼬치 2012.06.26 4193
Board Pagination Prev 1 ... 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 ... 516 Next
/ 516