질문과 답변

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 12442
RMVXA Script 'Cache' line 106: RGSSError occurred. 해결법좀요... 게임만들고싶어요 2016.05.05 565
RMVX script 'cache' line 80 revenir 2016.03.01 155
RMVX script 'Cache' line 80 오류가 떠요. 1 file 아민 2011.02.18 1214
기타 script 'cache' line 80: RGSSError ocurred. Failed to creat bitmap revenir 2016.03.02 173
RMVXA Script 'VGA' line 1015 에러가납니다 1 spome19 2014.07.07 1938
RMMV secret passage(숨겨진 통로) 같은 것을 만들 수 있을까요? 4 파란소리 2018.04.27 174
RMXP self.contents 선언 관련 1 Irr 2014.06.13 823
RMVX SE가 자동 반복되요.. 2 onicole 2013.11.25 874
RMXP SE가 재생 도중에 갑자기 끊기고 게임 렉이 심합니다. 1 CJYG* 2011.12.28 2313
RMXP se반복하는 스크립트는 없을까요? 2 CJYG* 2012.03.26 2134
이벤트 작성 RMMV se정지가 동작하지않아요 파닥이 2020.06.08 61
기타 SHIFT키를 누르면 자동으로 계속 왼쪽을 향합니다 ­… 3 작은펭귄 2014.02.19 835
RMXP Shun 님의 마우스 스크립트 file 이랏챠 2013.09.29 1214
RMVXA side view 방식의 게임을 만드려고 합니다 .. 3 보노노 2012.08.31 991
RMMV side view 전투 대형(formation) 만들기 2 file 삡코 2016.08.02 330
RMVXA SideView100으로 마법쓰면 스크립트 에러 나네요.. 11 file DMT3-이카 2012.09.10 1466
턴제 전투 RMMZ skill notetag가 뭔가요? 2 하라아아암 2023.08.29 31
RMXP Skill Shop 스크립트 선행스킬 판정 추가 방법 4 모모아이 2012.06.26 997
RMVX SMAMS 스크립트 오류 3 라테일gm 2015.01.09 290
RMVXA Spriteset_Map 클래스에서 추가적인 비트맵을 생성해 불러온 후, 변수에 따라 다른 이미지 불러오기 3 안나카레리나 2018.09.02 75
Board Pagination Prev 1 ... 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ... 516 Next
/ 516