Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[ONE BUG]Window_ShopStatus Request

Introduction
I am looking for a custom shop script. I don't require any fancy features like taxes, or limited supplies. The default system is just fine for my uses except for one thing. The Window_ShopStatus portion of shops is HORRIBLE! Comparing one stat on weapons and only two stats on armor and accessories is unacceptable. My RGSS capabilities are limited to minor edits of positioning and such and thus I haven't been able to script this myself.

The Request
Okay enough rambling and on to my request. I would like when the player shops he/she gets the entire breakdown of the item's stats that he/she is buying. There is only so far I can go with the description of items and including exactly how much the item raises each stat would leave no room for the actual description of the item. The characters that can't use the item do not have to display the stat names that could be blank if they cannot use the item.

That being said here is a mock-up of how I would like this system to look.
http://img145.imageshack.us/img145/3051/windowshopstatushl6.th.png[/img]
The color coordinated increases and decreases are important, although I can edit that part myself if you don't feel like tackling that part.

I don't think this would be too hard of a script aside from figuring out how to make all the descriptions fit whilst still having a 4 person party. I don't have a preference on how the windows are laid out so long as all the information of the item is displayed underneath each party member that can use said item. Lastly I need this script in a NON-SDK format. I have too much of my game completed to find new scripts for all my SDK incompatible scripts.

Summary
-I need a custom shop that displays all attributes of any given weapon/armor/accessory for all characters that can use the item.
-Color coordinated increases and decreases.
-Window arrangement is not important, default configuration would be fine so long as all the attributes can be fit.
-Must be Non-SDK version.
-Must not be pasted over the default Window_ShopStatus but overwriting it instead.

Thanks for your time and if there is anything I wasn't clear on please post here and I'll try my best to clarify. Of course any assistance I receive will be credited in my game. (Shop Tutorial as well as Ending Credits)
 

khmp

Sponsor

I would be happy to work on this Mr. jessy.laws if you have no objections. The earliest time I can start would be Sunday. I just have a few questions though.
-Not a rewrite of Window_ShopStatus but a standalone script
What do you mean by we can't rewrite this window? That window seems to be the one you would want to overwrite if I'm reading your description correctly. Or do you mean that the script shouldn't just be pasted over the original default script? But just override it? Or do you mean a separate window entirely to displays the differences in stats?
 
Right, I'm sorry i should have been clearer, yes i don't want it to be pasted over the default script but to override it. And thank you for taking this on, this is quite possibly the last script that I'll need for my game. (All my systems are already in place except my shop)

EDIT:
I've updated my first post to try and clarify the matter of overriding.
 

khmp

Sponsor

Insert an empty section above Main and paste in this code. It is non-SDK. The text is tiny but it's the only way to make it all seen. If you have any questions on it don't hesitate to ask.

Code:
#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
#  This class is hilarious.
#==============================================================================

class Bitmap
  #--------------------------------------------------------------------------
  # * Draw Shadowed Text
  #     x        : the x position
  #     y        : the y position
  #     width    : the width we can draw within.
  #     height   : the height we can draw within.
  #     text     : the text to be drawn.
  #     align    : the alignment of the text.
  #     offset_x : the offset in the x that the shadow will be from the text.
  #     offset_x : the offset in the y that the shadow will be from the text.
  #     s_color  : the color of the shadow that will be drawn.
  #--------------------------------------------------------------------------
  def draw_shadow_text(x, y, width, height, text, align = 0, offset_x = 1, 
      offset_y = 1, s_color = Color.new(0, 0, 0, 100))
    # Save the color so we can restore it afterwards.
    orig_color = self.font.color.dup
    
    # Draw the shadow first.
    self.font.color = s_color
    self.draw_text(x + offset_x, y + offset_y, width + offset_x, 
      height + offset_y, text, align)
    
    # Draw actual text.
    self.font.color = orig_color
    self.draw_text(x, y, width, height, text, align)
  end
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  WLH = 24
  #--------------------------------------------------------------------------
  # * Draw Gradient Rect
  #--------------------------------------------------------------------------
  def draw_gradient_rect(x, y, width, height, color1, color2)
    for i in 0...width
      f_color2 = i / width.to_f
      f_color1 = 1.0 - f_color2
      self.contents.fill_rect(x + i, y, 1, height,
        Color.new(color1.red * f_color1 + color2.red * f_color2,
        color1.green * f_color1 + color2.green * f_color2,
        color1.blue * f_color1 + color2.blue * f_color2,
        color1.alpha * f_color1 + color2.alpha * f_color2))
    end
  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
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Small_Font_Size = 14
  Stat_Gain_Color = Color.new(50, 255, 50)
  Stat_Loss_Color = Color.new(255, 50, 50)
  #--------------------------------------------------------------------------
  # * Refresh                                                      !OVERRIDE!
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    
    # Can't draw if there's no item to draw.
    return if @item.nil?
    
    # Make an array of stats to display
    @stats = ['P. Defense', 'M. Defense', 'Strength', 'Dexterity', 
      'Intelligence', 'Agility']
    
    # Decide what type of inventory we are looking at.
    case @item
    when RPG::Item
      number = $game_party.item_number(@item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(@item.id)
      @stats.unshift('Attack Power')
    when RPG::Armor
      number = $game_party.armor_number(@item.id)
      @stats.unshift('Evasion')
    end
    
    x = y = 0
    
    # Draw the number in possession.
    self.contents.font.size = Font.default_size
    self.contents.font.color = system_color
    self.contents.draw_shadow_text(x, y, width - 32, WLH, 'In Inventory: ')
    self.contents.font.color = normal_color
    self.contents.draw_shadow_text(x, y, width - 36, WLH, number.to_s, 2)
      
    # No need to draw anymore if the object is an item
    return if @item.is_a?(RPG::Item)
    
    # Increment our draw position.
    y += WLH + 1
    col_offset_x = [0, (width - 32) >> 1]
    col_width = (width - 32) >> 1
    
    # Equipment adding information
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      
      self.contents.font.color = actor.equippable?(@item) ? 
        normal_color : disabled_color

      # Draw actor's name
      self.contents.font.size = Font.default_size
      draw_gradient_rect(x, y + (WLH * 3 * i), width - 32, 1, 
        Color.new(128, 128, 128), Color.new(64, 64, 64))
      self.contents.draw_shadow_text(x, y + (WLH * 3 * i), width - 32, WLH, 
        actor.name)
      
      # Get current equipment
      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
      
      next if item1.nil?
      
      # If equippable
      if actor.equippable?(@item)
        diff = []
        # Figure out weapon attack
        if @item.is_a?(RPG::Weapon)
          diff << [@item.atk - item1.atk, actor.base_atk]
        else
          diff << [@item.eva - item1.eva, actor.base_eva]
        end
        diff << [@item.pdef - item1.pdef, actor.base_pdef]
        diff << [@item.mdef - item1.mdef, actor.base_mdef]
        diff << [@item.str_plus - item1.str_plus, actor.base_str]
        diff << [@item.dex_plus - item1.dex_plus, actor.base_dex]
        diff << [@item.agi_plus - item1.agi_plus, actor.base_agi]
        diff << [@item.int_plus - item1.int_plus, actor.base_int]
        
        # Set the font size to something a little more manageable.
        offset_y = y + (WLH * 3 * i) + 16
        self.contents.font.size = Small_Font_Size
        for j in 0...@stats.size
          col = [j / 3, 1].min
          new_x = col_offset_x[col]
          new_y = col > 0 ? 
            offset_y + ((j % 4) * Small_Font_Size) + Small_Font_Size :
            offset_y + ((j % 3) * Small_Font_Size) + Small_Font_Size
          
          new_y -= Small_Font_Size if col > 0
          
          self.contents.font.color = normal_color
          self.contents.draw_shadow_text(new_x, new_y, col_width, 
            Small_Font_Size, @stats[j])
          
          # Draw the difference.
          if diff[j][0] == 0
            self.contents.font.color = normal_color
          elsif diff[j][0] > 0
            self.contents.font.color = Stat_Gain_Color
          else
            self.contents.font.color = Stat_Loss_Color
          end
          self.contents.draw_shadow_text(new_x + 50, new_y, 64, 
            Small_Font_Size, diff[j][1].to_s + ' - ' + 
            (diff[j][1] + diff[j][0]).to_s, 2, 0, 1)
        end
      end
    end
  end
end

Good luck with it jessy.laws! :thumb:
 
This is wonderful, it works perfect with no bugs only one bug! Thanks a million Khmp and i'll be sure I credit you as I said I would. :)

EDIT: Errr scratch that no bugs, when using Guillaume777's Multi-Slot Equipment Script it shows the attack for both weapons even though I'm not using that script for weapons. Is there a quick edit for this to ignore the other weapons slot? Here's a screenshot of what I mean.

http://img228.imageshack.us/img228/776/examplehw2.png[/img]
17.0 - 22.0 is the issue in question. If i could get the second weapon stat to be removed everything would be wonderful.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top