Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Bob423

[Resolved] Custom shop script

Recommended Posts

I need a new shop script...

I found this one: http://rmrk.net/index.php?topic=24291.0

But I'm having a hard time editing it to fit the way my stats are set up.

This shows how the stats are shown in the equipment menu

post-17220-0-97512400-1394770387_thumb.png

I want the stats to be shown like that and for the characters to not be shown in a 2x2 grid, since the player can only have 3 in battle at one time.

 

IMPORTANT: the names of the stats in the menu are not named for what they are in the scripts because my stats are weird!

 

ATK in my game is STR by default

DEF is DEX

INT is still INT

SPD is AGI

HIT is PDEF (I don't want to explain it again)

PWR is ATK

RES is MDEF

and LUK is LUK (custom stat)

 

If someone could make a shop system with a similar menu layout, in addition to my specifications, that would be awesome.

Share this post


Link to post
Share on other sites
#==============================================================================
# ** Window_ShopBuy By Black Mage
#------------------------------------------------------------------------------
#  This window displays buyable goods on the shop screen.
#==============================================================================

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     shop_goods : goods
  #--------------------------------------------------------------------------
  def initialize(shop_goods)
    super(0, 128, 640, 128)
    @shop_goods = shop_goods
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Item Acquisition
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0
        item = $data_items[goods_item[1]]
        number = $game_party.item_number(@item.id)
      when 1
        item = $data_weapons[goods_item[1]]
        number = $game_party.weapon_number(@item.id)
      when 2
        item = $data_armors[goods_item[1]]
        number = $game_party.armor_number(@item.id)
      end
      if item != nil
        @data.push(item)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @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
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    # Get items in possession
    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 price is less than money in possession, and amount in possession is
    # not 99, then set to normal text color. Otherwise set to disabled color
    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)
    self.contents.draw_text(x + 260, y, 88, 32, "Price :")
    self.contents.draw_text(x + 300, y, 88, 32, item.price.to_s, 2)
    self.contents.draw_text(x + 470, y, 88, 32, "Owned :")
    self.contents.draw_text(x + 550, y, 32, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
#  This window displays number of items in possession and the actor's equipment
#  on the shop screen.
#==============================================================================

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 256, 640, 224)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item = nil
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  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
    if @item.is_a?(RPG::Item)
      return
    end
    # Equipment adding information
    for i in 0...$game_party.actors.size
      # Get actor
      actor = $game_party.actors[i]
      # If equippable, then set to normal text color. If not, set to
      # invalid text color.
      if actor.equippable?(@item)
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      # Get current equipment
      if @item.is_a?(RPG::Weapon)
        check = $data_weapons[actor.weapon_id]
        if check ==nil
          oldwpnstr = 0
          oldwpndex = 0
          oldwpnint = 0
          oldwpnagi = 0
          oldwpnpdf = 0
          oldwpnmdf = 0
          atkwpn = 0
        else
        oldwpnstr = $data_weapons[actor.weapon_id].str_plus
        oldwpndex = $data_weapons[actor.weapon_id].dex_plus
        oldwpnint = $data_weapons[actor.weapon_id].int_plus
        oldwpnagi = $data_weapons[actor.weapon_id].agi_plus
        oldwpnpdf = $data_weapons[actor.weapon_id].pdef
        oldwpnmdf = $data_weapons[actor.weapon_id].mdef
        atkwpn = @item.atk
        end
      elsif @item.kind == 0
        check = $data_armors[actor.armor1_id]
        if check ==nil
          oldwpnstr = 0
          oldwpndex = 0
          oldwpnint = 0
          oldwpnagi = 0
          oldwpnpdf = 0
          oldwpnmdf = 0
          atkwpn = 0
        else
        oldwpnstr = $data_armors[actor.armor1_id].str_plus
        oldwpndex = $data_armors[actor.armor1_id].dex_plus
        oldwpnint = $data_armors[actor.armor1_id].int_plus
        oldwpnagi = $data_armors[actor.armor1_id].agi_plus
        oldwpnpdf = $data_armors[actor.armor1_id].pdef
        oldwpnmdf = $data_armors[actor.armor1_id].mdef
        atkwpn = 0
        end
      elsif @item.kind == 1
        check = $data_armors[actor.armor2_id]
        if check ==nil
          oldwpnstr = 0
          oldwpndex = 0
          oldwpnint = 0
          oldwpnagi = 0
          oldwpnpdf = 0
          oldwpnmdf = 0
          atkwpn = 0
        else
        oldwpnstr = $data_armors[actor.armor2_id].str_plus
        oldwpndex = $data_armors[actor.armor2_id].dex_plus
        oldwpnint = $data_armors[actor.armor2_id].int_plus
        oldwpnagi = $data_armors[actor.armor2_id].agi_plus
        oldwpnpdf = $data_armors[actor.armor2_id].pdef
        oldwpnmdf = $data_armors[actor.armor2_id].mdef
        atkwpn = 0
        end
      elsif @item.kind == 2
        check = $data_armors[actor.armor3_id]
        if check ==nil
          oldwpnstr = 0
          oldwpndex = 0
          oldwpnint = 0
          oldwpnagi = 0
          oldwpnpdf = 0
          oldwpnmdf = 0
          atkwpn = 0
        else
        oldwpnstr = $data_armors[actor.armor3_id].str_plus
        oldwpndex = $data_armors[actor.armor3_id].dex_plus
        oldwpnint = $data_armors[actor.armor3_id].int_plus
        oldwpnagi = $data_armors[actor.armor3_id].agi_plus
        oldwpnpdf = $data_armors[actor.armor3_id].pdef
        oldwpnmdf = $data_armors[actor.armor3_id].mdef
        atkwpn = 0
        end
      else
        check = $data_armors[actor.armor4_id]
        if check ==nil
          oldwpnstr = 0
          oldwpndex = 0
          oldwpnint = 0
          oldwpnagi = 0
          oldwpnpdf = 0
          oldwpnmdf = 0
          atkwpn = 0
        else
        oldwpnstr = $data_armors[actor.armor4_id].str_plus
        oldwpndex = $data_armors[actor.armor4_id].dex_plus
        oldwpnint = $data_armors[actor.armor4_id].int_plus
        oldwpnagi = $data_armors[actor.armor4_id].agi_plus
        oldwpnpdf = $data_armors[actor.armor4_id].pdef
        oldwpnmdf = $data_armors[actor.armor4_id].mdef
        atkwpn = 0
        end
      end

      # Draw item
      x = 4 + 213*i
      y = 24
        
      # Draw actor's name
      self.contents.draw_text(4 + 213*i, -8, 120, 32, actor.name)
      
      # Draw ATK = STR
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.draw_text(x, y-2, 212, 32, "ATK")
      act = actor.str
      wpn = @item.str_plus - oldwpnstr
      self.contents.draw_text(88 + 213*i, y-2, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y-2, 112, 32, sprintf("%+d", wpn), 2)

      # Draw DEF = DEX
      self.contents.draw_text(x, y+19, 212, 32, "DEF")
      act = actor.dex
      wpn = @item.dex_plus - oldwpndex
      self.contents.draw_text(88 + 213*i, y+19, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y+19, 112, 32, sprintf("%+d", wpn), 2)
        
      # Draw INT = INT
      self.contents.draw_text(x, y+40, 212, 32, "INT")
      act = actor.int
      wpn = @item.int_plus - oldwpnint
      self.contents.draw_text(88 + 213*i, y+40, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y+40, 112, 32, sprintf("%+d", wpn), 2)

      # Draw SPD = AGI
      self.contents.draw_text(x, y+61, 212, 32, "SPD")
      act = actor.agi
      wpn = @item.agi_plus - oldwpnagi
      self.contents.draw_text(88 + 213*i, y+61, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y+61, 112, 32, sprintf("%+d", wpn), 2)

      # Draw HIT = PDEF
      self.contents.draw_text(x, y+82, 212, 32, "HIT")
      act = actor.pdef
      wpn = @item.pdef - oldwpnpdf
      self.contents.draw_text(88 + 213*i, y+82, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y+82, 112, 32, sprintf("%+d", wpn), 2)

      # Draw PWR = ATK
      self.contents.draw_text(x, y+103, 212, 32, "PWR")
      act = actor.atk
      self.contents.draw_text(88 + 213*i, y+103, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y+103, 112, 32, sprintf("%+d", atkwpn), 2)

      # Draw RES = MDEF
      self.contents.draw_text(x, y+124, 212, 32, "RES")
      act = actor.mdef
      wpn = @item.mdef - oldwpnmdf
      self.contents.draw_text(88 + 213*i, y+124, 112, 32, act.to_s(10))
      self.contents.draw_text(64 + 213*i, y+124, 112, 32, sprintf("%+d", wpn), 2)

      # Custom Stat : LUK
      self.contents.draw_text(x, y+145, 212, 32, "LUK")

#      act = actor current LUK

#      wpn = Equip LUK - current Equip LUK

#      self.contents.draw_text(88 + 213*i, y+124, 112, 32, act.to_s(10))
#      self.contents.draw_text(64 + 213*i, y+124, 112, 32, sprintf("%+d", wpn), 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #     item : new item
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
end

There you go. I hope it's good enough :p

I've made it to just show the status increase for just the top 3 party.

It also showing all of your renamed statuses, including the custom one.

Since you have a custom stat called LUK, I've left some instruction on how to figure the thing works inside the script.

 

I'm not putting the equipment data like the script you reffered above, since I think it'll be enough with just showing the status increase, and I'm too lazy to do it :p

And yes, I was too lazy too, to color some of the statuses and their names to make them more beautiful :v

Share this post


Link to post
Share on other sites

Awesome! Thanks :D

Don't worry about the color, I can do that myself anyway :P

Probably should've mentioned I only use 2 armor slots...

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...