Sign in to follow this  
Followers 0
xXDarkDragonXx

KGC_ItemGrouping

3 posts in this topic

KGC_ItemGrouping
Por: KGC

Este script lo que hace es que organiza tus objetos, armas, armaduras, etc en 5 categorías:

Normal
Especial
Arma
Armadura
Importante


Primero, si no tienen el KGC_Module, vayan:

Tema de KGC_Module

OKs, creamos clase nueva arriba de Main y dentro de la misma le ponemos dentro esto:

[spoiler]
CODE
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/  � アイ� � � 類 � KGC_ItemGrouping�
#_/----------------------------------------------------------------------------
#_/ アイãƒ� ãƒ� を種類別ã?«åˆ� é¡žã?™ã‚‹å‡¦ç?� を追å� � ã?—ã?¾ã?™ã€‚
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズé� …ç›® ★
#==============================================================================

module KGC

ITEM_GROUP_ELEMENTS = ["Standar", "Especial", -1, -2, "Importante", 0]


ITEM_GROUP_NAME = ["Normal", "Especial", "Armas", "Armadura", "Importante"]

ITEM_GROUP_HELP = ["Aquí están objetos básicos",
  "Aquí encuentras objetos especiales",
  "Aquí encuentras las armas",
  "Aquí encuentras las armaduras",
  "Aquí encuentras objetos importantes"]
end

#★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★

$imported["ItemGrouping"] = true
$game_special_elements["item_hide"] = $data_system.elements.index("item_hide")

module KGC
ITEM_GROUP = []
for i in 0...ITEM_GROUP_ELEMENTS.size
  if ITEM_GROUP_ELEMENTS[i].is_a?(Numeric) && ITEM_GROUP_ELEMENTS[i] <= 0
    ITEM_GROUP[i] = ITEM_GROUP_ELEMENTS[i]
    next
  end
  key = "item_#{i}}"
  $game_special_elements[key] = $data_system.elements.index(ITEM_GROUP_ELEMENTS[i])
  ITEM_GROUP[i] = $game_special_elements[key]
end
end
class Object
include KGC
end

#★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★

#==============================================================================
# â–�  Module_RPG
#------------------------------------------------------------------------------
#  RPGモジュールå� ?定義
#==============================================================================

module RPG
class Item
  def usable?
    if $game_party.item_can_use?(self.id)
      return true
    end
    return false
  end
end
unless $imported["UsableWeapon"]
class Weapon
  def usable?
    return false
  end
end
end
end

#★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★

#==============================================================================
# â–�  Window_Item
#------------------------------------------------------------------------------
#  アイ� � 画���トル画���所�アイ� � �一覧を表示�るウィンドウ��。
#==============================================================================

class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# � オブジェクト�期化
#--------------------------------------------------------------------------
alias initialize_KGC_ItemGrouping initialize
def initialize
  initialize_KGC_ItemGrouping
  unless $game_temp.in_battle
    unless $imported["HelpExtension"]
      self.y += 64
      self.height -= 64
    end
    self.index = -1
    self.active = false
  end
end
#--------------------------------------------------------------------------
# � �表示判定
#     index : アイãƒ� ãƒ� ID
#     type  : 種別(0:アイãƒ� ãƒ�   1:武器  2:防具)
#--------------------------------------------------------------------------
def hide?(index, type = 0)
  case type
  when 0  
    elements = $data_items[index].element_set.dup
  when 1  
    elements = $data_weapons[index].element_set.dup
  when 2  
    elements = $data_armors[index].guard_element_set.dup
  end
  return elements.include?($game_special_elements["item_hide"])
end
#--------------------------------------------------------------------------
# � � 類後�アイ� � リストを�得
#     itemkind : アイãƒ� ãƒ� ã?®ç¨®åˆ¥
#--------------------------------------------------------------------------
def itemlist(itemkind)
  @data = []
  unless $game_temp.in_battle

    if ITEM_GROUP[itemkind] == 0
      for i in 1...$data_items.size
        if $game_party.item_number(i) > 0 && !self.hide?(i, 0)
          @data.push($data_items[i])
        end
      end
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 && !self.hide?(i, 1)
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 && !self.hide?(i, 2)
          @data.push($data_armors[i])
        end
      end
    elsif ITEM_GROUP[itemkind] == -1
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 && !self.hide?(i, 1)
          @data.push($data_weapons[i])
        end
      end
    elsif ITEM_GROUP[itemkind] == -2
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 && !self.hide?(i, 2)
          @data.push($data_armors[i])
        end
      end
    else
      for i in 1...$data_items.size
        if $game_party.item_number(i) > 0 && !self.hide?(i, 0) &&
            $data_items[i].element_set.include?(ITEM_GROUP[itemkind])
          @data.push($data_items[i])
        end
      end
    end
  else
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0 && !self.hide?(i, 0)
        @data.push($data_items[i])
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0 && !self.hide?(i, 1) && $data_weapons[i].usable?
        @data.push($data_weapons[i])
      end
    end
  end
end
#--------------------------------------------------------------------------
# � リフレッシュ
#     itemkind : アイãƒ� ãƒ� ã?®åˆ� é¡ž
#--------------------------------------------------------------------------
def refresh(itemkind = 0)
  if self.contents != nil
    self.contents.dispose
    self.contents = nil
  end
  self.itemlist(itemkind)
  @item_max = @data.size
  if @item_max > 0
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max
      draw_item(i)
    end
  end
end
#--------------------------------------------------------------------------
# â—? é� …ç›®ã?®æ??ç”»
#     index : é� …目番å?·
#--------------------------------------------------------------------------
def draw_item(index)
  item = @data[index]
  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
  if (item.is_a?(RPG::Item) && item.usable?) ||
      ($game_temp.in_battle && item.is_a?(RPG::Weapon) && item.usable?)
    self.contents.font.color = normal_color
  else
    self.contents.font.color = disabled_color
  end
  x = 4 + index % 2 * (288 + 32)
  y = index / 2 * 32
  rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  bitmap = RPG::Cache.icon(item.icon_name)
  opacity = self.contents.font.color == normal_color ? 255 : 128
  self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  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
end

#★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★

#==============================================================================
# â–�  Window_ItemGroup
#------------------------------------------------------------------------------
#  アイãƒ� ãƒ� ç”»é?¢ã?§ã€?åˆ� é¡žã‚’é?¸æ� žã?™ã‚‹ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã?§ã?™ã€‚
#==============================================================================

class Window_ItemGroup < Window_Selectable
#--------------------------------------------------------------------------
# � オブジェクト�期化
#--------------------------------------------------------------------------
def initialize
  super(0, 64, 640, 64)
  self.contents = Bitmap.new(width - 32, height - 32)
  @commands = []
  for name in ITEM_GROUP_NAME
    @commands.push(name)
  end
  @item_max = @commands.size
  @column_max = @commands.size
  @item_width = (width - 32) / @commands.size
  self.index = 0
  refresh
end
#--------------------------------------------------------------------------
# � リフレッシュ
#--------------------------------------------------------------------------
def refresh
  for i in [email protected]
    rect = Rect.new(@item_width * i, 0, @item_width, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.font.color = system_color
    self.contents.draw_text(rect, @commands[i], 1)
  end
end
#--------------------------------------------------------------------------
# � カーソル�矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
  if index != -1
    self.cursor_rect.set(@item_width * index, 0, @item_width, 32)
  end
end
#--------------------------------------------------------------------------
# � ヘルプ� キスト更新
#--------------------------------------------------------------------------
def update_help
  @help_window.set_text(ITEM_GROUP_HELP[self.index])
end
end

#★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★� ★

#==============================================================================
# â–�  Scene_Item
#------------------------------------------------------------------------------
#  アイ� � 画��処� を行� クラス��。
#==============================================================================

class Scene_Item
#--------------------------------------------------------------------------
# � メイン処�
#--------------------------------------------------------------------------
alias main_KGC_ItemGrouping main
def main
  # åˆ� 類ウィンドウを作æˆ?
  @group_window = Window_ItemGroup.new
  @group_window.back_opacity = 160 if $imported["MenuAlter"]

  # å…ƒã?®å‡¦ç?� を実行
  main_KGC_ItemGrouping

  # ウィンドウを解放
  @group_window.dispose
end
#--------------------------------------------------------------------------
# � フレー� 更新
#--------------------------------------------------------------------------
def update
  unless @window_initialize
    @group_window.z = @help_window.z + 1
    @group_window.help_window = @help_window
    @window_initialize = true
  end
  @help_window.update
  @item_window.update
  @target_window.update
  @group_window.update
  # update_item
  if @item_window.active
    update_item
    return
  end
  #update_target
  if @target_window.active
    update_target
    return
  end
  # update_group
  if @group_window.active
    update_group
    return
  end
end
#--------------------------------------------------------------------------
# â—? フレーãƒ� æ›´æ–° (アイãƒ� ãƒ� ウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ)
#--------------------------------------------------------------------------
alias update_item_KGC_ItemGrouping update_item
def update_item
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    @group_window.active = true
    @group_window.visible = true
    @item_window.active = false
    @item_window.index = -1
    return
  end

  update_item_KGC_ItemGrouping
end
#--------------------------------------------------------------------------
# â—? フレーãƒ� æ›´æ–° (ターゲットウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ)
#--------------------------------------------------------------------------
def update_target
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    unless $game_party.item_can_use?(@item.id)
      @item_window.refresh(@group_window.index)
    end
    @item_window.active = true
    @target_window.visible = false
    @target_window.active = false
    return
  end
  if Input.trigger?(Input::C)
    if $game_party.item_number(@item.id) == 0
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    if @target_window.index == -1
      used = false
      for i in $game_party.actors
        used |= i.item_effect(@item)
      end
    end
    if @target_window.index >= 0
      target = $game_party.actors[@target_window.index]
      used = target.item_effect(@item)
    end
    if used
      $game_system.se_play(@item.menu_se)
      if @item.consumable
        $game_party.lose_item(@item.id, 1)
        @item_window.draw_item(@item_window.index)
      end
      @target_window.refresh
      if $game_party.all_dead?
        $scene = Scene_Gameover.new
        return
      end
      if @item.common_event_id > 0
        $game_temp.common_event_id = @item.common_event_id
        $scene = Scene_Map.new
        return
      end
    end
    unless used
      $game_system.se_play($data_system.buzzer_se)
    end
    return
  end
end
#--------------------------------------------------------------------------
# â—? フレーãƒ� æ›´æ–° (åˆ� 類ウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ)
#--------------------------------------------------------------------------
def update_group
  if @now_itemkind != @group_window.index
    @item_window.refresh(@group_window.index)
    @now_itemkind = @group_window.index
  end
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Menu.new(0)
    return
  end
  if Input.trigger?(Input::C)
    $game_system.se_play($data_system.decision_se)
    @item_window.active = true
    @item_window.index = 0
    @group_window.active = false
    @group_window.visible = false if $imported["HelpExtension"]
    return
  end
end
end
[/spoiler]

Ahora, vayan a:

Base de Datos -> Sistema

En Atributos, ponen 4 más. Los llamarán nombrarán) en el siguiente orden:

Standar
Especial
Importante
item_hide


Y ahora, vayan a la pestaña de objetos (noten que solo deben ponerle el atributo deseado a objetos, las armaduras y armas de organizan solas) y le dan el atributo deseado a cada objeto.

Standar es para objetos básicos
Especial... pa' que más... objetos especiales. xD.png
Importante... la palabra lo dice. o_O
item_hide es para que no se muestre ese objeto.

Que lo disfruten. happy.gif
0

Share this post


Link to post
Share on other sites
Gracias x el script, creo que estaba en el antiguo foro y me kede con ganas de cogerlo, lo cojo ahora vale? xD.png xD.png un buen aporte happy.gif
0

Share this post


Link to post
Share on other sites
Sí, es un script muy interesante, pero como use todos los scripts interesantes tendré un proyecto con más de 50 scripts. xD.png
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0