Akianzax

AR3 ~ HUD

Jun 27th, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.72 KB | None | 0 0
  1. #                            ~ Akian~RGSS3 ~
  2.  
  3. # Nombre del script: AR3 ~ HUD
  4. # Scripter: Akian~RGSS3
  5. # Requiere?: -
  6. # Versión: 1.4
  7.  
  8. # Historial:
  9. # 1.0 Comienzo y Finalización del script
  10. # 1.1 Añadida barra de experiencia
  11. # 1.2 Corregido bug de actualización del nombre del mapa
  12. # 1.3 Agregada más edición
  13. # 1.4 Rework completo + agregado de playtime. Se quitó el ícono de oro y el oro.
  14.  
  15. # Este script permite un HUD en el mapa totalmente modificable, mostrando el
  16. # nombre del lider del grupo, su hp, también el nombre del mapa.
  17. # El script está pensado para no usar imágenes, ser sencillo y elegante, además
  18. # (la parte más importante) ser totalmente modificable, no se requiere
  19. # mucho conocimiento, solo un poco de sentido común
  20.  
  21. #===============================================================================
  22. # Condiciones de uso:
  23. # Puedes usar libremente este script en proyectos comerciales y no comerciales
  24. # Los créditos son requeridos, por el trabajo, el esfuerzo, el sudor, bueno no
  25. # tanto por el sudor.
  26. # Si posteas este script en algún foro debes señalar la página oficial
  27. # http://akianzax.wix.com/akian-rgss3
  28. # También nombrar la página en los créditos si lo usas para un proyecto.
  29. #===============================================================================
  30.  
  31. $imported = {} if $imported.nil?
  32. $imported["AR3_HUD"] = true
  33.  
  34. module AR3_HUD
  35. #==============================================================================
  36. #
  37. #                         REGION EDITABLE
  38. #
  39. #==============================================================================  
  40.   FONT_NAME = "Comic Sans MS"      # Fuente
  41.   FONT_SIZE = 18                   # Tamaño de fuente
  42.   PLAYTIME_FONT       = "Verdana"  # Fuente del T.juego
  43.   PLAYTIME_FONT_SIZE  = 18         # Tamaño T.juegp
  44.   SWITCH_ID = 6
  45.  
  46. # Posiciones del Hud     x       y
  47.   ACTOR_NAME_POSITION = [0,      0]
  48.   ACTOR_HP_POSITION   = [0,     23]
  49.   ACTOR_EXP_POSITION  = [0,     40]
  50.   ACTOR_LEVEL_POSITION = [65,     0]
  51.   MAP_NAME_POSITION   = [-25 , -30]
  52.   PLAYTIME_POSITION   = [0   ,  325]
  53.  
  54. end
  55.  
  56. module AR3_HUD_VOCAB
  57.   EXP_WORD = "Exp"           # Palabra para definir experiencia
  58.   PLAYTIME_WORD = "T. Juego" # Palabra para definir playtime
  59.  
  60. # Aquí se van a definir los colores de los números y palabras del HUD
  61. #           Map   Level  n°Level  Vida  BarraVida1   BarraVida2
  62.   COLORS  = [27,   24,    26,      8,      2,            18,
  63. #         MinHp y Max   T.juego    Exp  BarraExp1    BarraExp2
  64.              2,           0,       31,     30,           31,
  65. #         Nombre del actor
  66.             23]
  67.            
  68. # Colores 0 = Blanco || 1 = Celeste || 2 = Rojo || 3 = Verde || 4 = Celeste(Claro)
  69. # 5 = Lila || 6 = Amarillo || 7 = Gris(Oscuro) || 8 = Gris ||  9 = Azul
  70. # 10 = Rojo(Fuerte) || 11 = Verde(Fuerte) || 12 = Azul(Fuerte) || 13 = Violeta
  71. # 14 = Naranja || 15 = Negro || 16 = Lila(Suave) || 17 = Amarillo
  72. # 18 = Rojo || 19 = Negro || 20 = Marron || 21 = Marron(Claro) || 22 = Azul(Agua)
  73. # 23 = Celeste(Fuerte) || 24 = Verde(Claro) || 25 = Marron(Raro)
  74. # 26 = Violeta || 27 = Rosado || 28 = Verde(Fuerte) || 29 = Verde(Claro)
  75. # 30 = Violeta(Fuerte) || 31 = Violeta(Suave)
  76. # Esto teniendo el windowskin normal, con otros puede ser igual o no, prueben.
  77.  
  78.  
  79. #==============================================================================
  80. #
  81. #                      FIN DE LA REGION EDITABLE
  82. #
  83. #==============================================================================            
  84. end
  85.  
  86. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. # Class Window
  88. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  89. class Window_Hud < Window_Base  
  90.   include AR3_HUD
  91.   include AR3_HUD_VOCAB
  92.   #--------------------------------------------------------------------------
  93.   # ▼ Initialize
  94.   #--------------------------------------------------------------------------  
  95.   def initialize
  96.     super(0, 0, Graphics.width, Graphics.height)
  97.     self.contents.font.name = FONT_NAME
  98.     self.contents.font.size = FONT_SIZE
  99.     self.opacity = 0
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ▼ No actualizar tono
  103.   #--------------------------------------------------------------------------  
  104.   def update_tone
  105.   end
  106.  
  107.   #--------------------------------------------------------------------------
  108.   # ▼ Colores de los textos
  109.   #--------------------------------------------------------------------------
  110.   def normal_color;      text_color(0);   end;    # Normal
  111.   def system_color;      text_color(16);  end;    # System
  112.   def crisis_color;      text_color(17);  end;    # Crisis
  113.   def knockout_color;    text_color(18);  end;    # Knock out
  114.   def gauge_back_color;  text_color(19);  end;    # Gauge background
  115.   def hp_gauge_color1;   text_color(COLORS[4]);   end;    # HP gauge 1
  116.   def hp_gauge_color2;   text_color(COLORS[5]);  end;    # HP gauge 2
  117.   def actor_name_color;  text_color(COLORS[11]);  end;    # Actor name
  118.   def exp_gauge1;        text_color(COLORS[9]);  end;    # Exp gauge 1
  119.   def exp_gauge2;        text_color(COLORS[10]);  end;    # Exp gauge 2
  120.   def exp_vocab;         text_color(COLORS[8]);  end;    # Exp word
  121.   def hp_min_max;        text_color(COLORS[6]);   end;    # Hp min and max
  122.   def vocab_hp;          text_color(COLORS[3]);   end;    # Vocab hp
  123.   def level_word;        text_color(COLORS[1]);  end;    # Level Word
  124.   def level_num;         text_color(COLORS[2]);  end;    # Level number
  125.   def map_word;          text_color(COLORS[0]);  end;    # Map word
  126.   def playtime_word;     text_color(COLORS[7]);   end;    # Playtime word
  127.  
  128.   #--------------------------------------------------------------------------
  129.   # ▼ Seteando el hud
  130.   #--------------------------------------------------------------------------    
  131.   def set_hud
  132.     draw_actor_name($game_party.leader, ACTOR_NAME_POSITION[0], ACTOR_NAME_POSITION[1])
  133.     draw_actor_hp($game_party.leader,ACTOR_HP_POSITION[0], ACTOR_HP_POSITION[1])
  134.     draw_exp($game_party.leader, ACTOR_EXP_POSITION[0], ACTOR_EXP_POSITION[1])
  135.     draw_actor_level($game_party.leader, ACTOR_LEVEL_POSITION[0], ACTOR_LEVEL_POSITION[1])
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ▼ Seteando mapa y playtime
  139.   #--------------------------------------------------------------------------
  140.   def set_misc
  141.     self.contents.clear
  142.     draw_map(MAP_NAME_POSITION[0], MAP_NAME_POSITION[1], $game_map.display_name)
  143.     draw_playtime(PLAYTIME_POSITION[0], PLAYTIME_POSITION[1])
  144.   end  
  145.   #--------------------------------------------------------------------------
  146.   # ▼ Dibujando mapa
  147.   #--------------------------------------------------------------------------
  148.   def draw_map(x, y, text)
  149.     self.contents.font.name = FONT_NAME
  150.     self.contents.font.size = FONT_SIZE
  151.     change_color(map_word)
  152.     draw_text(x, y, Graphics.width, 100, text, 2)
  153.     draw_icon(231, Graphics.width - (text.size * 6 + 65).to_f , y + 37)
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ▼ Dibujando playtime
  157.   #--------------------------------------------------------------------------
  158.   def draw_playtime(x, y)
  159.     self.contents.font.name = PLAYTIME_FONT
  160.     self.contents.font.size = PLAYTIME_FONT_SIZE
  161.     change_color(playtime_word)
  162.     draw_text(x, y, Graphics.width * 0.5, 100, $game_system.playtime_s)
  163.     draw_text(x, y-20, Graphics.width * 0.5, 100, PLAYTIME_WORD)
  164.   end
  165.  
  166.   #--------------------------------------------------------------------------
  167.   # * Draw Name
  168.   #--------------------------------------------------------------------------
  169.   def draw_actor_name(actor, x, y, width = 112)
  170.     change_color(actor_name_color)
  171.     draw_text(x, y, width, line_height, actor.name)
  172.   end  
  173.   #--------------------------------------------------------------------------
  174.   # * Draw Level
  175.   #--------------------------------------------------------------------------
  176.   def draw_actor_level(actor, x, y)
  177.     change_color(level_word)
  178.     draw_text(x, y, 32, line_height, Vocab::level_a)
  179.     change_color(level_num)
  180.     draw_text(x + 10, y, 24, line_height, actor.level, 2)
  181.   end  
  182.   #--------------------------------------------------------------------------
  183.   # * Draw HP
  184.   #--------------------------------------------------------------------------
  185.   def draw_actor_hp(actor, x, y, width = 80)
  186.     draw_gauge(x+30, y+5, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  187.     change_color(vocab_hp)
  188.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  189.     draw_current_and_max_values(x-12, y, width+40, actor.hp, actor.mhp,
  190.       hp_min_max, hp_min_max)
  191.   end  
  192.   #--------------------------------------------------------------------------
  193.   # ▼ Dibujando exp gauge
  194.   #--------------------------------------------------------------------------  
  195.   def draw_exp_gauge(x, y, width, rate, color1, color2)
  196.     fill_w = (width * rate).to_i
  197.     gauge_y = y + line_height - 8
  198.     contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
  199.     contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
  200.   end  
  201.   #--------------------------------------------------------------------------
  202.   # ▼ Dibujando exp gauge
  203.   #--------------------------------------------------------------------------
  204.   def draw_exp(actor, x, y, width = 80)
  205.         s1 = actor.max_level? ? "---------" : actor.exp
  206.         s2 = actor.max_level? ? "0" : actor.next_level_exp - actor.exp
  207.         if actor.max_level? ?
  208.           draw_exp_gauge(x+28, y+5, width, 5, exp_gauge1, exp_gauge2) :
  209.           draw_gauge(x+28, y+5, width,((((actor.exp - actor.current_level_exp).to_f/100) / ((actor.next_level_exp.to_f - actor.current_level_exp.to_f)/100))),  
  210.           exp_gauge1, exp_gauge2)
  211.         end
  212.         change_color(exp_vocab)
  213.         draw_text(x, y-35, 100, 100, EXP_WORD)  
  214.     end  
  215. end
  216.  
  217. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  218. # Class Scene_Map (se procesa todo lo relativo al mapa)
  219. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220. class Scene_Map < Scene_Base
  221.   include AR3_HUD
  222.  
  223.  alias akian_hud_start_zack    start
  224.  alias akian_hud_update_zack   update
  225. #--------------------------------------------------------------------------
  226. # ▼ Proceso de comienzo
  227. #--------------------------------------------------------------------------
  228.   def start
  229.     akian_hud_start_zack
  230.     create_hud_window
  231.     create_misc_window
  232. end
  233.  
  234. #--------------------------------------------------------------------------
  235. # ▼ Creando hud
  236. #--------------------------------------------------------------------------  
  237.    def create_hud_window
  238.      @set_hud = Window_Hud.new
  239.      @set_hud.set_hud
  240.      @set_hud.visible =  !$game_switches[SWITCH_ID]
  241.    end
  242. #--------------------------------------------------------------------------
  243. # ▼ Creando hud misc
  244. #--------------------------------------------------------------------------    
  245.    def create_misc_window
  246.      @set_misc = Window_Hud.new
  247.      @set_misc.set_misc
  248.      @set_misc.visible = !$game_switches[SWITCH_ID]    
  249.    end  
  250. #--------------------------------------------------------------------------
  251. # ▼ Actualizacion
  252. #--------------------------------------------------------------------------    
  253.    def update
  254.      akian_hud_update_zack
  255.      @set_misc.set_misc
  256.      @set_hud.visible  = !$game_switches[SWITCH_ID]
  257.      @set_misc.visible = !$game_switches[SWITCH_ID]
  258.   end
  259. end
  260.  
  261. #===============================================================================
  262. #
  263. #                 ▼ Fin del mundo, acá se acaba todo
  264. #                         ~  Akián RGSS3 ~
  265. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment