Advertisement
blackmorning

Blackmorning - Ace Shop

Nov 4th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.89 KB | None | 0 0
  1. #==============================================================================
  2. # ** Blackmorning -> Advanced Shop
  3. #------------------------------------------------------------------------------
  4. #  Blackmorning
  5. #  Version 2.00
  6. #  released 01/29/2014
  7. #  updated 11/05/2015
  8. # - added background image change
  9. # - can change opacity of shop scene
  10. #==============================================================================
  11. #  - INTRODUCTION -
  12. # - shows animated actor graphic for equipable items
  13. # - shows atk, def, mat, mdf changes for all equipment
  14. #==============================================================================
  15. # ? Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below BM - Base but above BM - Icon.
  19. # If using BM - Advanced Menu, put this below it.
  20. # Remember to save.
  21. #==============================================================================
  22. module BM
  23.   module SHOP
  24.     ITEM_EQUIPPED = "--Equipped--"
  25.     PARAM_FONT_SIZE = 18
  26.     PARAM_SHOWN = 2..7
  27.     PARAM_ICONS={
  28.       2 => 900, # ATK,   ATtacK power
  29.       3 => 901, # DEF,   DEFense power
  30.       4 => 902, # MAT,   Magic ATtack power
  31.       5 => 903, # MDF,   Magic DeFense power
  32.       6 => 904, # AGI,   AGIlity
  33.       7 => 905, # LUK,   LUcK  
  34.     } # DO NOT REMOVE
  35.     ACTOR_OPTIONS = { # for shop status window
  36.       :image   => :char,  #:face or :char to show scaled down face or the character graphic
  37.       :walk_char    => true, # walking actor graphics (may slow down game in menu)
  38.       :image_width  => 40, # width of face
  39.       :image_height => 50, # height of actor bar
  40.     }# DO NOT REMOVE
  41.     # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  42.     # Background Options
  43.     # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  44.     BG_OPTIONS ={
  45.       :win_opacity  => 255,    # window opacity for menu
  46.       :show_bg_img  => false, # show background image
  47.       :bg_image     => "Wallpaper",   # image name (Located in Graphics/System
  48.       :bg_opacity   => 255,  # background image opacity
  49.       :bg_scroll_x  => 0,    # horizontal movement
  50.       :bg_scroll_y  => 0,    # vertical movement
  51.     }# DO NOT REMOVE
  52.   end
  53. end
  54. #==============================================================================
  55. # Editting anything past this point may potentially result in causing computer
  56. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  57. # Therefore, edit at your own risk.
  58. #==============================================================================
  59. module BM
  60.   def self.required(name, req, version, type = nil)
  61.     if !$imported[:bm_base]
  62.       msg = "The script '%s' requires the script\n"
  63.       msg += "'BM - Base' v%s or higher above it to work properly\n"
  64.       msg += "Go to bmscripts.weebly.com to download this script."
  65.       msgbox(sprintf(msg, self.script_name(name), version))
  66.       exit
  67.     else
  68.       self.required_script(name, req, version, type)
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * script_name
  73.   #   Get the script name base on the imported value
  74.   #--------------------------------------------------------------------------
  75.   def self.script_name(name, ext = "BM")
  76.     name = name.to_s.gsub("_", " ").upcase.split
  77.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  78.     name.join(" ")
  79.   end
  80. end
  81. #==============================================================================
  82. $imported ||= {}
  83. $imported[:bm_shop] = 2.00
  84. BM.required(:bm_shop, :bm_base, 1.10, :above)
  85. #==============================================================================
  86. # ** Scene_Shop
  87. #==============================================================================
  88. class Scene_Shop < Scene_MenuBase
  89.   alias :bm_shop_start :start
  90.   def start
  91.     bm_shop_start
  92.     bm_win_opacity
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   def bm_win_opacity
  96.     @gold_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @gold_window.nil?
  97.     @help_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @help_window.nil?
  98.     @command_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @command_window.nil?
  99.     unless $imported["YEA-ShopOptions"]
  100.       @dummy_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @dummy_window.nil?
  101.     end
  102.     @number_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @number_window.nil?
  103.     @status_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @status_window.nil?
  104.     @buy_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @buy_window.nil?
  105.     @category_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @category_window.nil?
  106.     @sell_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @sell_window.nil?    
  107.     @data_window.opacity = BM::SHOP::BG_OPTIONS[:win_opacity] unless @data_window.nil?    
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # * Create Background Image
  111.   #--------------------------------------------------------------------------
  112.   alias :bm_shop_cb :create_background
  113.   def create_background
  114.     return bm_shop_cb unless custom_bg? && !$imported[:bm_menustatus]
  115.     custom_background
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   def custom_bg?
  119.     return false if BM::SHOP::BG_OPTIONS[:bg_image] == ""
  120.     return false unless BM::SHOP::BG_OPTIONS[:show_bg_img]
  121.     return true
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   def custom_background
  125.     @background_sprite = Plane.new
  126.     @background_sprite.bitmap = Cache.system(BM::SHOP::BG_OPTIONS[:bg_image])
  127.     @background_sprite.opacity = BM::SHOP::BG_OPTIONS[:bg_opacity]
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   def update_background
  131.     return if BM::SHOP::BG_OPTIONS[:bg_scroll_x] == 0 && BM::SHOP::BG_OPTIONS[:bg_scroll_y] == 0
  132.     @background_sprite.ox += BM::SHOP::BG_OPTIONS[:bg_scroll_x]
  133.     @background_sprite.oy += BM::SHOP::BG_OPTIONS[:bg_scroll_y]
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Update_Background_Image
  137.   #--------------------------------------------------------------------------
  138.   alias :bm_shop_u :update
  139.   def update
  140.     bm_shop_u
  141.     update_background if custom_bg? && !$imported[:bm_menustatus]
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Alias: create_actor_window
  145.   #--------------------------------------------------------------------------
  146.   alias :bm_shop_caw :create_actor_window if $imported["YEA-ShopOptions"]
  147.   def create_actor_window
  148.     bm_shop_caw    
  149.     @actor_window.hide
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Overwrite: show_sub_window
  153.   #--------------------------------------------------------------------------
  154.   def show_sub_window(window)
  155.     @status_window.hide
  156.     @gold_window.hide
  157.     window.show.activate
  158.   end  
  159.   #--------------------------------------------------------------------------
  160.   # * Overwrite: hide_sub_window
  161.   #--------------------------------------------------------------------------
  162.   def hide_sub_window(window)
  163.     @status_window.show
  164.     @gold_window.show
  165.     window.hide.deactivate
  166.     @command_window.activate
  167.   end
  168. end
  169. #==============================================================================
  170. # ** Window_ShopStatus
  171. #==============================================================================
  172. class Window_ShopStatus < Window_Base
  173.   #--------------------------------------------------------------------------
  174.   # * Alias: Initialize
  175.   #--------------------------------------------------------------------------
  176.   alias :bm_shop_init :initialize
  177.   def initialize(x, y, width, height)
  178.     @walk = 0
  179.     @step = 0  # 0 is left, 1 is right
  180.     @animtime = 0
  181.     @e_images = {}
  182.     bm_shop_init(x, y, width, height)
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # * Alias: update
  186.   #--------------------------------------------------------------------------
  187.   alias :bm_shop_up :update
  188.   def update
  189.     super
  190.     if BM::SHOP::ACTOR_OPTIONS[:walk_char] && BM::SHOP::ACTOR_OPTIONS[:image] == :char
  191.       ani_motion
  192.       update_page
  193.     else; bm_shop_up
  194.     end
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # * Overwrite: Number of Actors Displayable at Once
  198.   #--------------------------------------------------------------------------
  199.   def page_size; member_size; end
  200.   #--------------------------------------------------------------------------
  201.   # new method: member_size
  202.   #--------------------------------------------------------------------------
  203.   def member_size
  204.     ms = $game_party.max_battle_members
  205.     minh = BM::SHOP::ACTOR_OPTIONS[:image_height]
  206.     loop do
  207.       maxh = (contents.height - line_height*1.5)/ ms
  208.       if maxh >= minh; return ms; end
  209.       ms -= 1
  210.     end
  211.     return ms
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * New Method: col_height
  215.   #--------------------------------------------------------------------------
  216.   def col_height; (contents.height - line_height*1.5)/page_size; end
  217.   #--------------------------------------------------------------------------
  218.   # * Overwrite: Draw Equipment Information
  219.   #--------------------------------------------------------------------------
  220.   def draw_equip_info(x, y)
  221.     shown = BM::SHOP::PARAM_SHOWN; size = 0
  222.     for id in shown; size += 1; end      
  223.     width = (contents.width-32)/size; dx = 0
  224.     contents.font.size = BM::SHOP::PARAM_FONT_SIZE
  225.     for id in shown
  226.       icon1 = BM::SHOP::PARAM_ICONS[id]
  227.       draw_icon(Icon.param(id), x + 36 + width*dx, y - line_height) if $imported[:bm_icon]
  228.       draw_icon(icon1, x + 36 + width*dx, y - line_height)
  229.       dx += 1
  230.     end
  231.     status_members.each_with_index do |actor, i|
  232.       draw_actor_equip_info(x, y + col_height*i, actor)
  233.     end
  234.     reset_font_settings
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Overwrit: draw_actor_equip_info
  238.   #--------------------------------------------------------------------------
  239.   def draw_actor_equip_info(dx, dy, actor)
  240.     enabled = actor.equippable?(@item)
  241.     change_color(normal_color, enabled)
  242.     item1 = current_equipped_item(actor, @item.etype_id)
  243.     iwidth = BM::SHOP::ACTOR_OPTIONS[:image_width]
  244.     iheight = BM::SHOP::ACTOR_OPTIONS[:image_height]
  245.     image_rect = Rect.new(dx, dy, iwidth, iheight)
  246.     contents.fill_rect(dx, dy, contents_width, col_height, standby_color(actor))
  247.     if BM::SHOP::ACTOR_OPTIONS[:image] == :face
  248.       draw_icon_face(actor, image_rect, enabled)
  249.     elsif BM::SHOP::ACTOR_OPTIONS[:image] == :char
  250.       draw_actor_graphic(actor, dx + 16, dy + iheight - 6, enabled)
  251.     end
  252.     y = (iheight - line_height)/2
  253.     draw_actor_param_change(dx + 32, dy + y, actor, item1) if enabled
  254.   end  
  255.   #--------------------------------------------------------------------------
  256.   # * Overwrite: draw_actor_param_change
  257.   #--------------------------------------------------------------------------
  258.   def draw_actor_param_change(x, y, actor, item1)
  259.     shown = BM::SHOP::PARAM_SHOWN; size = 0
  260.     for id in shown; size += 1; end      
  261.     width = (contents.width-32)/size; dx = 0
  262.     dx = 0
  263.     for id in shown
  264.       if @item == item1
  265.         draw_text(x, y, contents.width - x, line_height, BM::SHOP::ITEM_EQUIPPED, 1)
  266.         return
  267.       end
  268.       change = actor_param_change_value(actor, item1, id)
  269.       change_color(param_change_color(change))
  270.       text = change.group
  271.       text = "+" + text if change >= 0
  272.       text = "--" if change == 0
  273.       draw_icon(Icon.param_compare(change), x + width*dx, y) if $imported[:bm_icon]  
  274.       draw_text(x + width*dx, y, width, line_height, text, 1)
  275.       dx += 1
  276.     end
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # * New Method: actor_param_change_value
  280.   #--------------------------------------------------------------------------
  281.   def actor_param_change_value(actor, item1, id)
  282.     n = @item.params[id] - (item1 ? item1.params[id] : 0)
  283.     return n unless $imported["YEA-EquipDynamicStats"]
  284.     n += @item.per_params[id] * actor.param_base(id) rescue 0
  285.     n += $game_variables[@item.var_params[id]] rescue 0
  286.     n -= item1.per_params[id] * actor.param_base(id) rescue 0
  287.     n -= $game_variables[item1.var_params[id]] rescue 0
  288.     return n
  289.   end
  290. end
  291.  
  292. #===============================================================================
  293. #
  294. # END OF FILE
  295. #
  296. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement