¡Bienvenid@ a Mundo Maker!

¿Quieres aprender todo sobre el RPG Maker?



Regístrate y forma parte de Mundo Maker.
Conectarse

Recuperar mi contraseña

Temas importantes
----------------------------------------
Páginas con recursos RPG Maker
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
Afiliados
Estadísticas
Tenemos 3393 miembros registrados.
El último usuario registrado es nino34.

Nuestros miembros han publicado un total de 79784 mensajes en 11253 argumentos.
Navega con Google Chrome
[DESCARGA]

[XP] Scene_Shop : Cambiar de actor con Q/W

 :: RPG Maker :: Scripts

Ver el tema anterior Ver el tema siguiente Ir abajo

[XP] Scene_Shop : Cambiar de actor con Q/W

Mensaje por Wecoc el 2015-01-23, 23:50

Pues eso, como en Scene_Equip y Scene_Status se puede cambiar de actor con Q/W, cambié la Scene_Shop para que también se pueda. De ese modo caben más parámetros ahí si se desea.

Para cambiar la info que sale en esa "nueva" ventana, se hace en el refresh de Window_ShopActor. En algún momento tengo pensado hacer un script de tienda más personalizada a partir de ésta misma base, pero de momento ésta es solo un aspecto técnico.

Código:
#==============================================================================
# * Window_Selectable
#==============================================================================

class Window_Selectable < Window_Base
 
  attr_accessor :qw_enabled
 
  alias qw_enabled_ini initialize unless $@
  def initialize(*args)
    qw_enabled_ini(*args)
    @qw_enabled = true
  end
 
  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      if Input.repeat?(Input::DOWN)
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
          @index < @item_max - @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      if Input.repeat?(Input::UP)
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
          @index >= @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      if Input.repeat?(Input::RIGHT)
        if @column_max >= 2 and @index < @item_max - 1
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      if Input.repeat?(Input::LEFT)
        if @column_max >= 2 and @index > 0
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      if @qw_enabled
        if Input.repeat?(Input::R)
          if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
            $game_system.se_play($data_system.cursor_se)
            @index = [@index + self.page_item_max, @item_max - 1].min
            self.top_row += self.page_row_max
          end
        end
        if Input.repeat?(Input::L)
          if self.top_row > 0
            $game_system.se_play($data_system.cursor_se)
            @index = [@index - self.page_item_max, 0].max
            self.top_row -= self.page_row_max
          end
        end
      end
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
end

#==============================================================================
# ** Window_ShopStatus
#==============================================================================

class Window_ShopStatus < Window_Base
  def initialize
    super(368, 128, 272, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item = nil
    refresh
  end

  def refresh
    self.contents.clear
    if @item == nil
      return
    end
    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
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 32, "Num. en posesión")
    self.contents.font.color = normal_color
    self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  end
end

#==============================================================================
# ** Window_ShopActor
#==============================================================================

class Window_ShopActor < Window_Base
 
  attr_accessor :actor
  attr_accessor :item
 
  def initialize(actor)
    super(368, 192, 272, 288)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    @item = nil
    refresh
  end

  def refresh
    self.contents.clear
    if @item == nil
      return
    end
    if @item.is_a?(RPG::Item)
      return
    end
    if !@actor.equippable?(@item)
      self.contents.font.color = disabled_color
      self.contents.draw_text(0, 0, 128, 32, @actor.name)
      return
    end
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 128, 32, @actor.name)
    if @item.is_a?(RPG::Weapon)
      item1 = $data_weapons[@actor.weapon_id]
    elsif @item.kind == 0
      item1 = $data_armors[@actor.armor1_id]
    elsif @item.kind == 1
      item1 = $data_armors[@actor.armor2_id]
    elsif @item.kind == 2
      item1 = $data_armors[@actor.armor3_id]
    else
      item1 = $data_armors[@actor.armor4_id]
    end
    # Weapon
    if @item.is_a?(RPG::Weapon)
      atk1 = item1 != nil ? item1.atk : 0
      atk2 = @item != nil ? @item.atk : 0
      change = atk2 - atk1
    end
    # Armor
    if @item.is_a?(RPG::Armor)
      pdef1 = item1 != nil ? item1.pdef : 0
      mdef1 = item1 != nil ? item1.mdef : 0
      pdef2 = @item != nil ? @item.pdef : 0
      mdef2 = @item != nil ? @item.mdef : 0
      change = pdef2 - pdef1 + mdef2 - mdef1
    end
    # Draw parameter change values
    self.contents.draw_text(124, 64, 112, 32, sprintf("%+d", change), 2)
    # Draw item
    if item1 != nil
      x = 4
      y = 64 + 32
      bitmap = RPG::Cache.icon(item1.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, item1.name)
    end
  end
 
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
 
  def actor=(actor)
    if @actor != actor
      @actor = actor
      refresh
    end
  end
end

#==============================================================================
# ** Window_ShopBuy
#==============================================================================

class Window_ShopBuy < Window_Selectable
  def initialize(shop_goods)
    super(0, 128, 368, 352)
    @qw_enabled = false
    @shop_goods = shop_goods
    refresh
    self.index = 0
  end
end

#==============================================================================
# ** Window_ShopSell
#==============================================================================

class Window_ShopSell < Window_Selectable
  def initialize
    super(0, 128, 368, 352)
    @qw_enabled = false
    refresh
    self.index = 0
  end

  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.price > 0
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 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)
    price = item.price / 2
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
end

#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================

class Scene_Shop
  def initialize
    @actor_index = 0
  end

  def main
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @command_window = Window_ShopCommand.new
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    @actor_window = Window_ShopActor.new(@actor)
    @actor_window.active = false
    @actor_window.visible = false
    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false
    @status_window = Window_ShopStatus.new
    @status_window.visible = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @command_window.dispose
    @actor_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
  end

  def update
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @sell_window.update
    @number_window.update
    @status_window.update
    @actor_window.update
    if @actor_window.visible
      update_actor
    end
    if @command_window.active
      update_command
      return
    end
    if @buy_window.active
      update_buy
      return
    end
    if @sell_window.active
      update_sell
      return
    end
    if @number_window.active
      update_number
      return
    end
  end

  def update_actor
    if Input.trigger?(Input::R)
      Graphics.freeze
      $game_system.se_play($data_system.cursor_se)
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      @actor = $game_party.actors[@actor_index]
      @actor_window.actor = @actor
      Graphics.transition
    end
    if Input.trigger?(Input::L)
      Graphics.freeze
      $game_system.se_play($data_system.cursor_se)
      @actor_index -= 1
      @actor_index %= $game_party.actors.size
      @actor = $game_party.actors[@actor_index]
      @actor_window.actor = @actor
      Graphics.transition
    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)
      case @command_window.index
      when 0  # buy
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
        @actor_window.visible = true
      when 1  # sell
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
        @status_window.visible = true
        @actor_window.visible = true
      when 2  # quit
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end

  def update_buy
    @status_window.item = @buy_window.item
    @actor_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @actor_window.visible = false
      @actor_window.item = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      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 number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
      max = [max, 99 - number].min
      @buy_window.active = false
      @buy_window.visible = false
      @number_window.set(@item, max, @item.price)
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
      @actor_window.visible = true
    end
  end

  def update_sell
    @status_window.item = @sell_window.item
    @actor_window.item = @sell_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @actor_window.visible = false
      @actor_window.item = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      @status_window.item = @item
      if @item == nil or @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      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
      max = number
      @sell_window.active = false
      @sell_window.visible = false
      @number_window.set(@item, max, @item.price / 2)
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
      @actor_window.visible = true
    end
  end

  def update_number
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # buy
        @buy_window.active = true
        @buy_window.visible = true
      when 1  # sell
        @sell_window.active = true
        @sell_window.visible = true
      end
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # buy
        $game_party.lose_gold(@number_window.number * @item.price)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.gain_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @buy_window.refresh
        @status_window.refresh
        @actor_window.refresh
        @buy_window.active = true
        @buy_window.visible = true
      when 1  # sell
        $game_party.gain_gold(@number_window.number * (@item.price / 2))
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @sell_window.refresh
        @status_window.refresh
        @actor_window.refresh
        @sell_window.active = true
        @sell_window.visible = true
      end
      return
    end
  end
end


No pido créditos.

Wecoc
Administrador
Administrador



Créditos 8265

Gracias : 372

Volver arriba Ir abajo

Re: [XP] Scene_Shop : Cambiar de actor con Q/W

Mensaje por Wecoc el 2015-01-24, 17:37

Ya he hecho otro script personalizado para la tienda.
Va bastante distinto, se llama por separado la tienda de Comprar y la de Vender, de ese modo podréis hacer que un evento solo pueda hacer una cosa u otra.

Para llamar la de Comprar se hace como siempre, y para llamar la de vender hay que usar éste código:
$scene = Scene_Shop.new(1)

Tampoco pido créditos.

Screens:
Spoiler:



^ Éste último es el equipo actual del héroe, para cambiar de héroe se hace con Q/W

Script:
Código:
#==============================================================================
# * Window_Selectable
#==============================================================================

class Window_Selectable < Window_Base
 
  attr_accessor :qw_enabled
 
  alias qw_enabled_ini initialize unless $@
  def initialize(*args)
    qw_enabled_ini(*args)
    @qw_enabled = true
  end
 
  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      if Input.repeat?(Input::DOWN)
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
          @index < @item_max - @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      if Input.repeat?(Input::UP)
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
          @index >= @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      if Input.repeat?(Input::RIGHT)
        if @column_max >= 2 and @index < @item_max - 1
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      if Input.repeat?(Input::LEFT)
        if @column_max >= 2 and @index > 0
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      if @qw_enabled
        if Input.repeat?(Input::R)
          if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
            $game_system.se_play($data_system.cursor_se)
            @index = [@index + self.page_item_max, @item_max - 1].min
            self.top_row += self.page_row_max
          end
        end
        if Input.repeat?(Input::L)
          if self.top_row > 0
            $game_system.se_play($data_system.cursor_se)
            @index = [@index - self.page_item_max, 0].max
            self.top_row -= self.page_row_max
          end
        end
      end
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
end

#==============================================================================
# ** Window_ShopStatus
#==============================================================================

class Window_ShopStatus < Window_Base
  def initialize(shop_index)
    super(0, 128, 320, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    @shop_index = shop_index
    @item = nil
    refresh
  end

  def refresh
    self.contents.clear
    if @item == nil
      return
    end
    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
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 32, "Precio")
    self.contents.font.color = normal_color
    if @shop_index == 0 # Comprar
      if $game_party.gold < @item.price
        self.contents.font.color = disabled_color
      end
      price = @item.price
    else
      price = @item.price / 2
    end
    self.contents.draw_text(204-36, 0, 96, 32, price.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(204+64, 0, 96, 32, $data_system.words.gold)
    self.contents.font.color = system_color
    self.contents.draw_text(4, 32, 200, 32, "Posesión")
    self.contents.font.color = normal_color
    if @shop_index == 0 # Comprar
      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 number == 99
        self.contents.font.color = disabled_color
      end
    end
    self.contents.draw_text(204-16, 32, 96, 32, number.to_s, 2)
  end
end

#==============================================================================
# ** Window_ShopActor
#==============================================================================

class Window_ShopActor < Window_Base
 
  attr_accessor :actor
  attr_accessor :item
 
  def initialize(actor)
    super(0, 320, 640, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    @item = nil
    refresh
  end

  def refresh
    self.contents.clear
    if @item == nil
      return
    end
    if @actor.equippable?(@item) or @item.is_a?(RPG::Item)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    # Draw Item name
    x = 4
    y = 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)
    if @item.is_a?(RPG::Item)
      return
    end
    # Draw Actor name
    self.contents.draw_text(0, 32, 128, 32, @actor.name)
    # Draw Actor level
    if @actor.equippable?(@item)
      self.contents.font.color = system_color
    end
    self.contents.draw_text(0, 64, 32, 32, "Lv")
    if @actor.equippable?(@item)
      self.contents.font.color = normal_color
    end
    self.contents.draw_text(32, 64, 24, 32, @actor.level.to_s, 2)
    # Draw Actor's equip
    if @item.is_a?(RPG::Weapon)
      item1 = $data_weapons[@actor.weapon_id]
    elsif @item.kind == 0
      item1 = $data_armors[@actor.armor1_id]
    elsif @item.kind == 1
      item1 = $data_armors[@actor.armor2_id]
    elsif @item.kind == 2
      item1 = $data_armors[@actor.armor3_id]
    else
      item1 = $data_armors[@actor.armor4_id]
    end
    if item1 != nil
      x = 4
      y = 64 + 32
      bitmap = RPG::Cache.icon(item1.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, item1.name)
    end
    # Draw parameter change values
    if @item.is_a?(RPG::Weapon)
      atk1 = item1 != nil ? item1.atk : 0
      atk2 = @item != nil ? @item.atk : 0
    else
      atk1 = 0
      atk2 = 0
    end
    pdef1 = item1 != nil ? item1.pdef : 0
    pdef2 = @item != nil ? @item.pdef : 0
    mdef1 = item1 != nil ? item1.mdef : 0
    mdef2 = @item != nil ? @item.mdef : 0
    atk = atk2 - atk1
    pdef = pdef2 - pdef1
    mdef = mdef2 - mdef1
    self.contents.font.color = disabled_color
    if @actor.equippable?(@item)
      self.contents.font.color = system_color
    end
    self.contents.draw_text(320, 32, 120, 32, $data_system.words.atk)
    self.contents.draw_text(320, 64, 120, 32, $data_system.words.pdef)
    self.contents.draw_text(320, 96, 120, 32, $data_system.words.mdef)
    if @actor.equippable?(@item)
      self.contents.font.color = normal_color
    end
    if atk >= 0
      self.contents.draw_text(500, 32, 120, 32, "+" + atk.abs.to_s)
    else
      self.contents.draw_text(500, 32, 120, 32, "-" + atk.abs.to_s)
    end
    if pdef >= 0
      self.contents.draw_text(500, 64, 120, 32, "+" + pdef.abs.to_s)
    else
      self.contents.draw_text(500, 64, 120, 32, "-" + pdef.abs.to_s)
    end
    if mdef >= 0
      self.contents.draw_text(500, 96, 120, 32, "+" + mdef.abs.to_s)
    else
      self.contents.draw_text(500, 96, 120, 32, "-" + mdef.abs.to_s)
    end
  end
 
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
 
  def actor=(actor)
    if @actor != actor
      @actor = actor
      refresh
    end
  end
end

#==============================================================================
# ** Window_ShopNumber
#==============================================================================

class Window_ShopNumber < Window_Base
  def initialize
    super(0, 224, 320, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item = nil
    @max = 1
    @price = 0
    @number = 1
  end

  def refresh
    self.contents.clear
    draw_item_name(@item, 4, 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(216, 0, 32, 32, "×")
    self.contents.draw_text(252, 0, 24, 32, @number.to_s, 2)
    self.cursor_rect.set(248, 0, 32, 32)
    # Draw total price and currency units
    domination = $data_system.words.gold
    cx = contents.text_size(domination).width
    total_price = @price * @number
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 272-cx-2, 32, total_price.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(276-cx, 32, cx, 32, domination, 2)
  end
end

#==============================================================================
# ** Window_ShopBuy
#==============================================================================

class Window_ShopBuy < Window_Selectable
  def initialize(shop_goods)
    super(320, 64, 320, 256)
    @qw_enabled = false
    @shop_goods = shop_goods
    refresh
    self.index = 0
  end
 
  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.price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 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)
  end
end

#==============================================================================
# ** Window_ShopSell
#==============================================================================

class Window_ShopSell < Window_Selectable
  def initialize
    super(320, 64, 320, 256)
    @qw_enabled = false
    refresh
    self.index = 0
  end

  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.price > 0
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 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)
  end
end

#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================

class Scene_Shop
  def initialize(shop_index=0)
    @shop_index = shop_index # 0 --> Buy, 1 --> Sell
    @actor_index = 0
  end

  def main
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @shop_window = Window_Base.new(0, 64, 160, 64)
    @shop_window.contents = Bitmap.new(160 - 32, 32)
    case @shop_index
    when 0
      @shop_window.contents.draw_text(0, 0, 160, 32, "Comprar")
    when 1
      @shop_window.contents.draw_text(0, 0, 160, 32, "Vender")
    end
    @gold_window = Window_Gold.new
    @gold_window.x = 160
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 224, 320, 96)
    if $game_temp.shop_goods == nil
      $game_temp.shop_goods = []
    end
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
    if @shop_index != 0
      @buy_window.active = false
      @buy_window.visible = false
    end
    @buy_window.help_window = @help_window
    @sell_window = Window_ShopSell.new
    if @shop_index != 1
      @sell_window.active = false
      @sell_window.visible = false
    end
    @sell_window.help_window = @help_window
    @actor_window = Window_ShopActor.new(@actor)
    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false
    @status_window = Window_ShopStatus.new(@shop_index)
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @actor_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
    @shop_window.dispose
  end

  def update
    @help_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @sell_window.update
    @number_window.update
    @status_window.update
    @actor_window.update
    @shop_window.update
    if @actor_window.visible
      update_actor
    end
    if @buy_window.active
      update_buy
      return
    end
    if @sell_window.active
      update_sell
      return
    end
    if @number_window.active
      update_number
      return
    end
  end

  def update_actor
    if Input.trigger?(Input::R)
      Graphics.freeze
      $game_system.se_play($data_system.cursor_se)
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      @actor = $game_party.actors[@actor_index]
      @actor_window.actor = @actor
      Graphics.transition
    end
    if Input.trigger?(Input::L)
      Graphics.freeze
      $game_system.se_play($data_system.cursor_se)
      @actor_index -= 1
      @actor_index %= $game_party.actors.size
      @actor = $game_party.actors[@actor_index]
      @actor_window.actor = @actor
      Graphics.transition
    end
  end
 
  def update_buy
    @status_window.item = @buy_window.item
    @actor_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      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 number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
      max = [max, 99 - number].min
      @buy_window.active = false
      @number_window.set(@item, max, @item.price)
      @number_window.active = true
      @number_window.visible = true
    end
  end

  def update_sell
    @status_window.item = @sell_window.item
    @actor_window.item = @sell_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      @status_window.item = @item
      if @item == nil or @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      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
      max = number
      @sell_window.active = false
      @number_window.set(@item, max, @item.price / 2)
      @number_window.active = true
      @number_window.visible = true
    end
  end

  def update_number
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @number_window.active = false
      @number_window.visible = false
      case @shop_index
      when 0  # buy
        @buy_window.active = true
      when 1  # sell
        @sell_window.active = true
      end
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      case @shop_index
      when 0  # buy
        $game_party.lose_gold(@number_window.number * @item.price)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.gain_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @buy_window.refresh
        @status_window.refresh
        @actor_window.refresh
        @buy_window.active = true
      when 1  # sell
        $game_party.gain_gold(@number_window.number * (@item.price / 2))
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @sell_window.refresh
        @status_window.refresh
        @actor_window.refresh
        @sell_window.active = true
      end
      return
    end
  end
end


Como arreglos fáciles que se le pueden hacer, se podría añadir el ataque actual al lado del "+0", y también especificar lo de Q/W para cambiar de héroe. También cambiar el color de la font según si es + o - y cosas así xD

Wecoc
Administrador
Administrador



Créditos 8265

Gracias : 372

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba


 :: RPG Maker :: Scripts

Permisos de este foro:
No puedes responder a temas en este foro.