질문과 답변

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 Mark.0 2018.09.10 156
RMMV mv 트라이얼 연댕 2018.09.09 78
RMMV 마우스 클릭 이동시 대쉬 안하고싶어요. 2 A구몽 2018.09.09 160
RMMV [자바스크립트] 메시지창이 게이지 위에 뜨게하기 6 file 몽롱하다 2018.09.09 192
RMVX 캐릭터의 자동이동 설정 2 시간측정기초시계 2018.09.08 342
알만툴2003 1.09버전 한패를 1.12버전에 부분적으로 적용하는 방법이 없을까요? 지나가던 2018.09.08 78
기타 혹시 맵타일중 XP맵타일크기룰 VX ACE로 바꿀방법없을까요? LWH 2018.09.06 130
RMMV 총만들기 16 초보입니다! 2018.09.04 456
RMVXA 사진을 띄우고 그위에 한장 더띄우고 싶은데 안나옵니다.. 2 Lamiassss3 2018.09.04 80
RMVX 노트북을 바꿔서 했는데 전에 만들었던게임이 2 골리버 2018.09.02 92
RMVXA Spriteset_Map 클래스에서 추가적인 비트맵을 생성해 불러온 후, 변수에 따라 다른 이미지 불러오기 3 안나카레리나 2018.09.02 75
RMMV 그림표시제한 100개를 넘기고 싶어요. 1 A구몽 2018.09.02 181
RMMV 특정 무기에만 이도류가 적용 가능하게 하는 방법이 뭔가요?? 2 쿄메 2018.09.01 116
기타 알만툴 게임 에딧 제작 질문 봉구빕스 2018.09.01 66
기타 여기서 받았던 작품에 있었던 BGM 출처를 알고 싶습니다. Ringccubus 2018.08.31 65
RMVXA 맵의 이벤트와 액터를 그림 위에 표시하기 3 file 안나카레리나 2018.08.31 268
RMVXA 메뉴 ui를 아예 뜯어 고칠 방법은 없는건가요? 3 Lamiassss3 2018.08.30 262
RMVXA 만들다보니.. 불편해서 여쭤봅니다. 5 Lamiassss3 2018.08.30 129
기타 rpg maker xp 캐릭터를 mv에 쓰고 싶은데요 2 BJ멜로 2018.08.30 199
RMVXA 게임플레이시 해상도를 1280x 720으로 하고싶습니다. 2 Lamiassss3 2018.08.29 228
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