MapEquip - Version 2.0

MapEquip - Equipaments on Map Screen
Version: 2.0
By Rafidelis(RafiScripts)

Introduction:

The first version of this script was released on September 22, 2008, when I started to learn RGSS.
So, after almost a year, was going through this topic and when I saw my script I thought 'aff, that horrible code!'.
Then decide totally rewrite the script, and this new version lags and bugs are almost impossible (see the feature session to see what's new.)

[center]Features


-View the equipment in the Vertical (|) or Horizontal (_)
-Displays the attack or defense of equipment.
-Show / Hide the equipment through a key.
-Use a background image if desired.
-Displaying a text, in 'empty' equipment slots
-Compatible with scripts that increase the amount of equipment slots.
-Updated only when some equipment is modified, thus totally avoids the possible lags.

Instructions


First up,paste above the main, then edit the settings in the editing section of the script, if the option to use image is active, the image should be in the picture folder, with the name defined in the script.See Screenshots section to find some images to use.

Screenshots


ImageImage

Images to be used as Background:
Image
Image
Image


Script

Script Spoiler
  1.  
  2. #==============================================================================#
  3. #                [RGSS2] Equipaments in Map Screen                             #
  4. #------------------------------------------------------------------------------#
  5. # $RafiScripts.by = Rafidelis(Rafis)                                           #
  6. # $RafiScripts.version = 1.0                                                   #
  7. # $RafiScripts.release_date = 09/09/09 (legal né?)  (d/m/y)                    #
  8. # $RafiScripts.email = [email hidden] or [email hidden]   #
  9. # $RafiScripts.website = http://www.ReinoRPG.com  or http://www.ReinoRPG.com/forum           #
  10. #==============================================================================#
  11.  
  12. #==============================================================================#
  13. # [** $RafiScripts.versions **]  // Versões do Script/ Script Versions         #
  14. #------------------------------------------------------------------------------#
  15. # 22/09/08 - Version 1.0 Released                                              #
  16. # 09/09/09 - Version 2.0 Released                                              #
  17. #==============================================================================#
  18.  
  19. #==============================================================================#
  20. # [** $RafiScripts.desc **]  // Sobre o Script / About Script                  #
  21. #------------------------------------------------------------------------------#
  22. # Este script,é uma nova versão de um velho script que criei,à uns 10 meses    #
  23. # atras.E claro,dessa vez uma versão aprimorada e melhor,totalmente sem lags.  #
  24. # O que este Script Faz? :Ele mostra na tela os equipamentos atuais do jogador #
  25. #------------------------------------------------------------------------------#
  26. # ** Features :                                                                #
  27. # (*) View the equipment in the Vertical (|) or Horizontal (_)                 #
  28. # (*) Displays the attack or defense of equipment.                             #
  29. # (*) Show / Hide the equipment through a key.                                 #
  30. # (*) Use a background image if desired.                                       #
  31. # (*) Displaying a text, in 'empty' equipment slots                            #
  32. # (*) Compatible with scripts that increase the amount of equipment slots.     #
  33. # (*) Updated only when some equipment is modified, thus totally avoids the    #
  34. #     possible lags ò.Ó                                                        #
  35. #------------------------------------------------------------------------------#
  36.  
  37. #==============================================================================#
  38. # [** $RafiScripts.instr ] // Instruções                                       #
  39. #------------------------------------------------------------------------------#
  40. # 1° Paste above the Main                                                      #
  41. # 2° Edit the constants in Module Rafidelis: MapEquip if you want.             #
  42. # 3° If you want to use a background image,it's must be in picture folder      #
  43. #------------------------------------------------------------------------------#
  44.  
  45. #==============================================================================#
  46. #                         [** Module Rafidelis ]                               #
  47. #[**Modulo necessario para rodar os Scripts criados por Rafidelis(RafiScripts)]#
  48. #==============================================================================#
  49. module Rafidelis
  50. #==============================================================================#
  51. # Rafidelis.add_script - Name : Name of Script - Version : Version of Script   #
  52. #------------------------------------------------------------------------------#
  53.   def self.add_script(name,version)
  54.     $RafiScripts = [] if $RafiScripts.nil?
  55.     $RafiScripts.push("Name : #{name} - Version: #{version}")
  56.   end
  57. #==============================================================================#
  58. # Rafidelis.script_exist? - Name : Name of Script - Version : Version of Script#
  59. #------------------------------------------------------------------------------#
  60.   def self.script_exist?(name,version)
  61.     $RafiScripts = [] if $RafiScripts.nil?
  62.     return $RafiScripts.include?("Name : #{name} - Version: #{version}")
  63.   end
  64. #==============================================================================#
  65. # Rafidelis.scripts - Return all scripts create by Rafidelis(RafiScripts)      #
  66. #------------------------------------------------------------------------------#
  67.   def self.scripts
  68.     print $RafiScripts
  69.   end
  70. #==============================================================================#
  71. # Rafidelis.create_txt - Create a .txt with all Rafidelis(RafiScripts) scripts #
  72. #------------------------------------------------------------------------------#
  73.   def self.create_txt(filename="RafideliScripts")
  74.     file = File.open("#{filename}.txt","wb")
  75.     for i in 0...$RafiScripts.size
  76.       file.write("#{$RafiScripts[i]}\r\n")
  77.     end
  78.   end
  79.   #============================================================================#
  80.   # (***) Modulo de Opções para o Script de Equipamento na Tela.               #
  81.   #============================================================================#
  82.   module MapEquip
  83.     # Adding the Script at the System. Don't Modify
  84.     name = "Equipaments in Map Screen"
  85.     version = "1.0"
  86.     Rafidelis.add_script(name,version)
  87.     # Script add at the System
  88.    
  89.     # Mode = use "V" -> Vertical or "H" -> Horizontal
  90.     Mode = "V"
  91.     # Background Picture,if you do not use leave the name in ".
  92.     BackGround_Image = "Equip_Back"
  93.     # Show equipaments informations ? -> Attack and Defense.
  94.     Display_Equip_Info = true
  95.     # Terms to be displayed before the attack power and defense power.
  96.     Terms = ["Atk : ","Def : "]
  97.     # Text Displayed when the equipament slot is empty.
  98.     No_Equip_Text = "Empty"
  99.     # Horizontal position of Equipment. Default -> - 10
  100.     Window_X = -10
  101.     # Vertical position of Equipment. Default -> - 10
  102.     Window_Y = -10
  103.     # Opacity of the window,recommended leave 0
  104.     Window_Opacity = 0
  105.     # Use the keyboard to Show / Hide the equipments?
  106.     Use_Input = true
  107.     # If Use_Input = true set down the key to be used.
  108.     # Set according the RPGMaker Default.See down some keys.
  109.     # "Key in RPGMaker" -> the original keyboard key.
  110.     # "A" -> Z : "Y" -> S : "Z" -> D : "X" - A : "L" -> Q : "R" -> W
  111.     Key = "X"
  112.     # If Use_Input = false, set down the ID of a switch to control
  113.     # Display of the Equipment on the screen.
  114.     Control_Switch_ID = 1
  115.   end
  116. end
  117. #==============================================================================#
  118. # [** $RafiScripts.conf_start ] \\ Inicio das Configurações                    #
  119. #------------------------------------------------------------------------------#
  120. # Verificando se o script esta incluso no sistema                              #
  121. #==============================================================================#
  122. name = "Equipaments in Map Screen"
  123. version = "1.0"
  124. if Rafidelis.script_exist?(name,version)
  125. #==============================================================================#
  126. # [** Window_Equipment **]                                                     #
  127. #------------------------------------------------------------------------------#
  128. #  (*) Esta Janela exibe os equipamentos do personagem principal no Mapa.      #
  129. #==============================================================================#
  130. class Window_Equipament < Window_Base
  131.   include Rafidelis::MapEquip
  132.   #============================================================================#
  133.   # (*) -> Inicialização do objeto                                             #
  134.   #----------------------------------------------------------------------------#
  135.   def initialize
  136.     dim = get_dimensions
  137.     super(Window_X,Window_Y,dim[0],dim[1])
  138.     self.opacity = Window_Opacity
  139.     self.contents.font.bold = true
  140.     refresh
  141.   end
  142.   #============================================================================#
  143.   # (*) -> Pegar as Dimensões de Altura e Largura da Janela.                   #
  144.   #----------------------------------------------------------------------------#
  145.   def get_dimensions
  146.     @mode = Mode
  147.     @bitmap = Cache.picture(BackGround_Image)
  148.     @equips = $game_party.members[0].equips
  149.     case @mode
  150.     when "H"
  151.       width = (@equips.size * @bitmap.width) + 32
  152.       height = @bitmap.height + 32
  153.     when "V"
  154.       width = @bitmap.width + 32
  155.       height = (@equips.size * @bitmap.height) + 32
  156.     end
  157.     return [width,height]
  158.   end
  159.   #============================================================================#
  160.   # (*) Refresh                                                                #
  161.   #----------------------------------------------------------------------------#
  162.   def refresh
  163.     self.contents.clear
  164.     bw = @bitmap.width ; bh = @bitmap.height
  165.     for i in 0...@equips.size
  166.       if @mode == "H"
  167.         x = i * bw
  168.         y = 0
  169.         tx = 5 + x
  170.       else
  171.         x = 0
  172.         y = i * bh
  173.         tx = 5 + x
  174.       end
  175.       self.contents.blt(x,y,@bitmap,@bitmap.rect)
  176.       if @equips[i].nil?
  177.         tw = contents.text_size(No_Equip_Text).width
  178.         self.contents.font.size = 15
  179.         self.contents.draw_text(tx,y,self.width,32,No_Equip_Text)
  180.       else
  181.         draw_equip_icon(@equips[i],x + 8,y + 5,Display_Equip_Info)
  182.       end
  183.     end
  184.   end
  185.   #============================================================================#
  186.   # (*) Mostrar os Icones dos Equipamentos                                     #
  187.   # item  :equipamento a ser exibido,pode ser tanto uma Arma ou Armadura.      #
  188.   # x : Posição x do Icone | y : Posição Y do Icone                            #
  189.   # show_text : Exibir as Informações de Ataque e Defesa do Equipamento.       #
  190.   #----------------------------------------------------------------------------#
  191.   def draw_equip_icon(item, x, y,show_text=false)
  192.     draw_icon(item.icon_index,x,y)
  193.     if item != nil
  194.       self.contents.font.size = 11
  195.       atk = Terms[0]
  196.       defense = Terms[1]
  197.       tw = contents.text_size(atk).width
  198.       tw2 = contents.text_size(defense).width
  199.       x = x - 6
  200.       y = y + 12
  201.       if show_text
  202.         if item.is_a?(RPG::Armor)
  203.           self.contents.font.color = text_color(2)
  204.           self.contents.draw_text(x, y,@bitmap.width,32,defense)
  205.           self.contents.font.color = normal_color
  206.           self.contents.draw_text(tw2 + x, y,@bitmap.width,32,"#{item.def}")
  207.         elsif item.is_a?(RPG::Weapon)
  208.           self.contents.font.color = text_color(2)
  209.           self.contents.draw_text(x, y,@bitmap.width, 32,atk)
  210.           self.contents.font.color = normal_color
  211.           self.contents.draw_text(tw + x, y,@bitmap.width, 32,"#{item.atk}")
  212.         end
  213.       end
  214.     end
  215.   end
  216.   #============================================================================#
  217.   # (*) Atualização | (*) Update                                               #
  218.   #----------------------------------------------------------------------------#
  219.   def update
  220.     if Use_Input
  221.       if Input.trigger?(eval("Input::#{Key}"))
  222.         if self.visible
  223.           self.visible = false
  224.         else
  225.           self.visible = true
  226.         end
  227.       end
  228.     elsif not Use_Input
  229.       self.visible = $game_switches[Control_Switch_ID]
  230.     end
  231.     actor = $game_party.members[0]
  232.     for i in 0...@equips.size
  233.       if @equips[i] != actor.equips[i]
  234.         @equips = $game_party.members[0].equips
  235.         refresh if self.visible
  236.       end
  237.     end
  238.   end
  239. end
  240. #==============================================================================#
  241. # Scene_Map                                                                    #
  242. #------------------------------------------------------------------------------#
  243. # Classe das operações nos mapas.                                              #
  244. #==============================================================================#
  245. class Scene_Map < Scene_Base
  246.   include Rafidelis::MapEquip
  247.   #============================================================================#
  248.   # (*) -> Aliase                                                              #
  249.   #----------------------------------------------------------------------------#
  250.   alias :rafidelis_mapequip_start      :start
  251.   alias :rafidelis_mapequip_update     :update
  252.   alias :rafidelis_mapequip_terminate  :terminate
  253.   #============================================================================#
  254.   # (*) -> Inicialização do processo                                           #
  255.   #----------------------------------------------------------------------------#
  256.   def start
  257.     @equip_window = Window_Equipament.new
  258.     $game_switches[Rafidelis::MapEquip::Control_Switch_ID] = true
  259.     rafidelis_mapequip_start
  260.   end
  261.   #============================================================================#
  262.   # (*) -> Atualização do processo                                             #
  263.   #----------------------------------------------------------------------------#  
  264.   def update
  265.     @equip_window.update
  266.     rafidelis_mapequip_update
  267.   end
  268.   #============================================================================#
  269.   # (*) -> Termininação do processo                                            #
  270.   #----------------------------------------------------------------------------#
  271.   def terminate
  272.      @equip_window.dispose
  273.      rafidelis_mapequip_terminate
  274.    end
  275.  end
  276.  # Fim da Verificação do Script no Sistema
  277. end
  278. #==============================================================================#
  279. # [** $RafiScripts.script_end] // Fim do Script - Script End                   #
  280. #------------------------------------------------------------------------------#
  281. # Você pode encontrar mais scripts meus em http://www.ReinoRPG.com                    #
  282. # You can find more scripts create for me at http://www.ReinoRPG.com                  #
  283. #==============================================================================#
  284.  
  285.  
Expand to see the code.



Terms of Use


- If you use this script, you do not have to include my name in
credits, but I'd like you to give the deserved credits; D
- You can use this script on non-commercial games, if you want to use in
some commercial game, please get in touch with me and we entered into an agreement.
- You can distribute / modify / edit this script, but can not withdraw
the name of the author and not the link to the forum ReinoRpg.
- Enjoy; D
This woud be pretty good for the VX abs' out there. Good Job, and It looks nice too.
Thanks for the compliments, and really this script works as a HUD for an ABS.
Later.
Awesome script. Maybe you could add a GUI to darg and drop the armor to equip it.
Thanks for the compliment,about the GUI, maybe one day I make a system like this.
Anyway, thank you.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=68328