RPGXP 스크립트
2013.10.01 06:09

아이템 조합 스크립트

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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

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

# ** Item Crafting System

#    version 1.01

#    created by arev (rmxp.pl), 일부 번역 : 페르 (T.Ignost)

#    released 28-12-2009, updated: 25-07-2010

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

# 설치 & 호환성

#

# 'Main' 위에 붙여넣으세요.

# RPG XP 기본 스크립트들과 호환됩니다. (SDK 등 다른 스크립트가 필요 없다는 뜻.)

# 가벼운 편이니 딱히 다른 스크립트들과도 부딫힐 일은 없을거에요.

#

# 사용법

#

# 이 글 아래에 '레시피'라고 쓰인 줄을 보실 수 있을거에요.

# 새 레시피를 만드려면 아래처럼 추가해주세요.

# ['i12', 'i78', 'w3', 'a45', 'a45', 'z', 'i-99']

# i는 아이템을, w는 무기를, a는 갑옷을 뜻합니다.

# 이 레시피에 따른다면 아이템 99번을 만들기 위해

# 12번 아이템, 78번 아이템, 3번 무기 하나,

# 45번 무기 둘이 필요합니다. 최대 6개까지 조합할 수 있습니다.

# 6개 이하로 조합하시려면

# 그 칸에 'z'를 써 넣어주세요.

# 마지막 항목은 레시피로 만들어질 결과물입니다.

#

#

# 조합창으로 이동하시려면

# $scene = Scene_Craft.new 을 이용해주세요.

#

# 항목에 쓴 아이템들의 순서는

# 스크립트 내에서 다시 재배열 되기 때문에 중요하진 않습니다.

#

#

#

# License:

#

# 비상업 목적으로만 이용하실 수 입니다.

# 이 스크립트를 재 배포하실 때는

# 원작자에게 허락을 받아야합니다.

#상업용도로 쓰시려면 아래로 연락해주세요.

# http://www.rmxp.pl or http://www.hbgames.org/forums private message system.

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


RECIPES = [

          ["i1", "w1", "z", "z", "z", "z", "a-1"],

         

          ]

#------------------------------------------------------------------------------

class Window_Craft_Components < Window_Selectable

 

  attr_accessor :data

 

  def initialize

    super(0, 64, 320, 224)

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

    self.index = 0

    self.active = true

    @data = [nil, nil, nil, nil, nil, nil]

    @item_max = 6

    refresh

  end

 

  def item

    return @data[self.index]

  end

 

  def refresh

    self.contents.clear

    for i in 0..5

      x = 0

      y = i * 32

      if @data[i] != nil

        item = @data[i]

        bitmap = RPG::Cache.icon(item.icon_name)

        self.contents.blt(4 + x, y + 4, bitmap, Rect.new(0, 0, 24, 24))

        self.contents.font.color = normal_color

        self.contents.draw_text(x + 32, y, 160, 32, item.name, 0)

      else

        self.contents.font.color = disabled_color

        self.contents.draw_text(4 + x, y, 160, 32, "빈 곳", 0)

      end

    end

  end

 

  def update_cursor_rect

    self.cursor_rect.set(0, self.index * 32, 288, 32)

  end

 

  def nullify

    @data = [nil, nil, nil, nil, nil, nil]

  end

 

  def transmutation

    temp = []

    for i in 0..5

      if @data[i] == nil

        temp << "0"

      else

        case @data[i]

        when RPG::Item

          temp << "i" + @data[i].id

        when RPG::Weapon

          temp << "w" + @data[i].id

        when RPG::Armor

          temp << "a" + @data[i].id

        end

      end

    end

    temp = temp.sort

    return temp

  end

 

end

#------------------------------------------------------------------------------

class Window_Craft_Result < Window_Base

 

  attr_accessor :item

 

  def initialize

    super(320,64,320,224)

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

    @item = nil

    @item_code = ""

    refresh

  end

 

  def refresh

    self.contents.clear

    if @item == nil

      self.contents.font.color = normal_color

      self.contents.draw_text(4,0,288,32, "우측 글씨", 0)

    else

      bitmap = RPG::Cache.icon(@item.icon_name)

      self.contents.font.color = text_color(6)

      self.contents.draw_text(4,0,288,32, "조합 결과", 0)

      self.contents.blt(4, 65, bitmap, Rect.new(0, 0, 24, 24))

      self.contents.font.color = normal_color

      self.contents.draw_text(32, 65, 288, 32, @item.name, 0)

      self.contents.font.color = disabled_color

      self.contents.draw_text(4,128,288,32, "조합 방법 - Z", 0)

      self.contents.draw_text(4,160,288,32, "", 0)

    end

  end

 

  def make_item(text="")

    @item_code = text

    if @item_code.include?("-")

      temp = @item_code.split("-")

      if text.include?("a")

        @item = $data_armors[temp[1].to_i]

      elsif text.include?("i")

        @item = $data_items[temp[1].to_i]

      elsif text.include?("w")

        @item = $data_weapons[temp[1].to_i]

      end

      refresh

    end

  end

 

  def nullify

    @item = nil

    refresh

  end

 

end

#------------------------------------------------------------------------------

class Window_Craft_Item < Window_Selectable

 

  def initialize

    super(0, 288, 640, 192)

    @column_max = 2

    refresh

    self.active = false

    self.index = -1

  end

 

  def item

    return @data[self.index]

  end

 

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    for i in 1...$data_items.size

      if $game_party.item_number(i) > 0

        @data.push($data_items[i])

      end

    end

    unless $game_temp.in_battle

      for i in 1...$data_weapons.size

        if $game_party.weapon_number(i) > 0

          @data.push($data_weapons[i])

        end

      end

      for i in 1...$data_armors.size

        if $game_party.armor_number(i) > 0

          @data.push($data_armors[i])

        end

      end

    end

    @data.push(nil)

    @item_max = @data.size

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

    for i in 0...@item_max-1

      draw_item(i)

    end

  end

 

  def draw_item(index)

    item = @data[index]

    x = 4 + index % @column_max * 320

    y = index / @column_max * 32

    case item

    when RPG::Item

      number = $game_party.item_number(item.id)

    when RPG::Weapon

      number = $game_party.weapon_number(item.id)

    when RPG::Armor

      number = $game_party.armor_number(item.id)

    end

    bitmap = RPG::Cache.icon(item.icon_name)

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))

    self.contents.font.color = normal_color

    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)

    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)

    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)

  end

 

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.description)

  end

 

  def update_cursor_rect

    if @index < 0

      self.cursor_rect.empty

      return

    end

    row = @index / @column_max

    if row < self.top_row

      self.top_row = row

    end

    if row > self.top_row + (self.page_row_max - 1)

      self.top_row = row - (self.page_row_max - 1)

    end

    x = index % @column_max * 320

    y = index / @column_max * 32 - self.oy

    self.cursor_rect.set(x, y, 288, 32)

  end

 

end

#------------------------------------------------------------------------------

class Scene_Craft

 

  def main

    @components = Window_Craft_Components.new

    @result = Window_Craft_Result.new

    @item_window = Window_Craft_Item.new

    @help_window = Window_Help.new

    @help_window.set_text("상단 글씨", 1)

    Graphics.transition

    loop do

      Input.update

      Graphics.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    @components.dispose

    @result.dispose

    @item_window.dispose

    @help_window.dispose

  end

 

  def update

    @item_window.update

    @components.update   

    if @components.active

      update_comp

      return

    end

    if @item_window.active

      update_item

      return

    end

  end

 

  def update_comp

    if Input.trigger?(Input::A)

      rock_baby

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      @components.active = false

      @item_window.active = true

      @item_window.index = 0

    end

    if Input.trigger?(Input::B)

      for i in 0..5

        item = @components.data[i]

        if item != nil

          case item

          when RPG::Item

            $game_party.gain_item(item.id, 1)

          when RPG::Weapon

            $game_party.gain_weapon(item.id, 1)

          when RPG::Armor

            $game_party.gain_armor(item.id, 1)

          end

        end

      end         

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Map.new

    end

  end

  def update_item

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      component = @components.data[@components.index]

      if component != nil

        case component

        when RPG::Item

          $game_party.gain_item(component.id, 1)

        when RPG::Weapon

          $game_party.gain_weapon(component.id, 1)

        when RPG::Armor

          $game_party.gain_armor(component.id, 1)

        end

      end

      item = @item_window.item

      @components.data[@components.index] = item

      case item

      when RPG::Item

        $game_party.lose_item(item.id, 1)

      when RPG::Weapon

        $game_party.lose_weapon(item.id, 1)

      when RPG::Armor

        $game_party.lose_armor(item.id, 1)

      end

      @item_window.refresh

      @components.refresh

      check_recipes

    

      @item_window.active = false

      @item_window.index = -1

      @components.active = true

    end

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @item_window.active = false

      @item_window.index = -1

      @components.active = true

    end

  end

 

  def check_recipes

    things_in_the_pot = []

    for i in 0..5

      case @components.data[i]

      when nil

        things_in_the_pot << "z"

      when RPG::Item

        things_in_the_pot << "i#{@components.data[i].id}"

      when RPG::Weapon

        things_in_the_pot << "w#{@components.data[i].id}"

      when RPG::Armor

        things_in_the_pot << "a#{@components.data[i].id}"

      end

    end

  

    things_in_the_pot = things_in_the_pot.sort

    for j in 0...RECIPES.size

      temp = RECIPES[j].dup

      temp.pop

      temp = temp.sort

      if things_in_the_pot == temp

        @result.make_item(RECIPES[j][6])

        return

      else

        @result.nullify

      end

    end

  end

 

  def rock_baby

    case @result.item

    when nil

      $game_system.se_play($data_system.buzzer_se)

    when RPG::Item

      $game_party.gain_item(@result.item.id, 1)

      finalize_crafting

    when RPG::Weapon

      $game_party.gain_weapon(@result.item.id, 1)

      finalize_crafting

    when RPG::Armor

      $game_party.gain_armor(@result.item.id, 1)

      finalize_crafting

    end

  end

 

  def finalize_crafting

    $game_system.se_play($data_system.save_se)

    @components.nullify

    @components.refresh

    @item_window.refresh

    @result.nullify

  end

end


 

?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수 추천 수
» RPGXP 스크립트 아이템 조합 스크립트 2013.10.01 890 0
187 RPGXP 스크립트 가상 키보드 입력 스크립트 2013.10.01 1660 0
186 RPGXP 스크립트 RPG 만들기 XP의 숨겨진 모듈/클래스 재정의 스크립트 모음 2013.10.01 1240 0
185 RPGXP 스크립트 빠른 길찾기 2 휴리드 2013.09.30 1336 0
184 RPGVX Ace 스크립트 텍스트 파일생성 1 휴리드 2013.09.30 654 0
183 RPGVX Ace 스크립트 파일 존재의 유무 체크 4 휴리드 2013.09.30 639 0
182 RPGXP 스크립트 네코에서 되는 마우스 스크립트 13 휴리드 2013.09.30 1675 0
181 RPGVX 스크립트 3D 그래픽 파티클 스크립트 1 청담 2013.09.29 1272 0
180 RPGXP 스크립트 일시정지 스크립트 2 청담 2013.09.29 929 0
179 RPGXP 스크립트 셀프 스위치 조작 4 청담 2013.09.29 656 0
178 RPGXP 스크립트 HBGames.ORG::Motion Blur 3 죽은노예 2013.09.27 771 0
177 RPGXP 스크립트 횡스크롤 스크립트 3  운 2013.09.27 1106 0
176 RPGXP 스크립트 FPS 표시 스크립트 7  운 2013.09.27 1166 0
175 RPGXP 스크립트 안티 렉 스크립트 2 2013.09.26 3327 1
174 RPGXP 스크립트 2D 마인크래프트 프로젝트 7 2013.09.26 3048 2
173 RPGXP 스크립트 정지 모션 스크립트 2 2013.09.26 713 1
172 RPGXP 스크립트 모든 글자에 외곽선을 넣어주는 스크립트 3 2013.09.26 808 1
171 RPGXP 스크립트 아이템 소지수 무제한 스크립트 청담 2013.09.24 1001 0
170 RPGXP 스크립트 메뉴에서 실제시간 보는 스크립트 4 청담 2013.09.24 607 0
169 RPGXP 스크립트 장비제련 스크립트 청담 2013.09.24 1024 0
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 15 Next
/ 15






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

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