Advertisement
Zetu

Z17::HUD v1.03

Jul 4th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.16 KB | None | 0 0
  1.                           #==========================#
  2.                           # Z17 Alternate HUD  v1.02 #
  3.                           #===#==================#===#
  4.                               #     by: Zetu     #
  5.                               #==================#
  6.                              
  7. module Z17
  8.   BATTLESYSTEM = 0
  9.   #  0 = Default Battle System
  10.   #  1 = Tankentai ATB
  11. end
  12.  
  13. module N02
  14.   ATB_PARTY_POSITION = []
  15.   for i in 0...Game_Party::MAX_MEMBERS
  16.     ATB_PARTY_POSITION.push([112 + i*128, 310])
  17.   end
  18. end
  19.  
  20. class Scene_Battle < Scene_Base
  21.  
  22.   alias z17_create_info_viewport create_info_viewport
  23.   def create_info_viewport
  24.     case Z17::BATTLESYSTEM
  25.     when 0
  26.       z17_create_info_viewport
  27.       @info_viewport.rect.y -= 128
  28.       @info_viewport.rect.height += 128
  29.       @status_window.x -= 128
  30.       @status_window.width += 128
  31.       @status_window.y += 128
  32.       @status_window.refresh
  33.       @party_command_window.y += 72
  34.       @party_command_window.column_max = @party_command_window.item_max
  35.       @party_command_window.height = 56
  36.       @party_command_window.width = @party_command_window.item_max*128
  37.       @party_command_window.spacing = 0
  38.       @party_command_window.create_contents
  39.       @party_command_window.refresh
  40.     when 1
  41.       @command_members = []
  42.       @action_battlers = []
  43.       @info_viewport = Viewport.new(0, 288, 544, 128)
  44.       @info_viewport.z = 100
  45.       @status_window = Window_BattleStatus.new
  46.       @party_command_window = Window_PartyCommand.new
  47.       @actor_command_window = Window_ActorCommand.new
  48.       @status_window.viewport = @info_viewport
  49.       @actor_command_window.viewport = @info_viewport
  50.       @status_window.x = 128
  51.       @actor_command_window.x = 672
  52.       @info_viewport.visible = false
  53.       @party_command_window.visible = false
  54.       @info_viewport.ox = 128
  55.       #--------
  56.       @info_viewport.rect.y -= 128
  57.       @info_viewport.rect.height += 128
  58.       @status_window.width += 128
  59.       @status_window.y += 128
  60.       @status_window.refresh
  61.       @party_command_window.column_max = @party_command_window.item_max
  62.       @party_command_window.height = 56
  63.       @party_command_window.width *= @party_command_window.item_max
  64.       @party_command_window.spacing = 0
  65.       @party_command_window.create_contents
  66.     end
  67.   end
  68.  
  69.   alias z17_start_target_enemy_selection start_target_enemy_selection
  70.   def start_target_enemy_selection
  71.     case Z17::BATTLESYSTEM
  72.     when 0
  73.       @target_enemy_window = Window_TargetEnemy.new
  74.       @target_enemy_window.y = @info_viewport.rect.y
  75.       @actor_command_window.active = false
  76.       @status_window.visible = false
  77.       @target_enemy_window.width += 128
  78.       @target_enemy_window.y += 128
  79.     when 1
  80.       z17_start_target_enemy_selection
  81.     end
  82.   end
  83.  
  84.   def end_target_enemy_selection
  85.     @status_window.visible = true
  86.     @target_enemy_window.dispose
  87.     @target_enemy_window = nil
  88.     if @actor_command_window.index == 0
  89.       @actor_command_window.active = true
  90.     end
  91.   end
  92.  
  93.   alias z17_start_target_actor_selection start_target_actor_selection
  94.   def start_target_actor_selection
  95.     case Z17::BATTLESYSTEM
  96.     when 0
  97.       @target_actor_window = Window_BattleStatus.new
  98.       @target_actor_window.index = 0
  99.       @target_actor_window.active = true
  100.       @target_actor_window.y = @info_viewport.rect.y + 128
  101.       @target_actor_window.width += 128
  102.       @target_actor_window.refresh
  103.       @actor_command_window.active = false
  104.       @status_window.visible = false
  105.     when 1
  106.       z17_start_target_actor_selection
  107.     end
  108.   end
  109.  
  110.   def end_target_actor_selection
  111.     @target_actor_window.dispose
  112.     @target_actor_window = nil
  113.     @status_window.visible = true
  114.   end
  115.  
  116.   def update_info_viewport
  117.     @party_command_window.update
  118.     @actor_command_window.update
  119.     @status_window.update
  120.     offset_party_window
  121.     offset_command_window
  122.   end
  123.  
  124.   if Z17::BATTLESYSTEM == 1
  125.     alias z17_start_party_command start_party_command
  126.     def start_party_command
  127.       z17_start_party_command
  128.       @party_command_window.column_max = @party_command_window.item_max
  129.       @party_command_window.height = 56
  130.       @party_command_window.width = @party_command_window.item_max*128
  131.       @party_command_window.spacing = 0
  132.       @party_command_window.create_contents
  133.       @party_command_window.refresh
  134.     end
  135.   end
  136.  
  137.   def offset_party_window
  138.     case Z17::BATTLESYSTEM
  139.     when 0; a, b = [0, -@party_command_window.width]
  140.     when 1; a, b = [0, -@party_command_window.width]
  141.     end
  142.     if @party_command_window.active and @party_command_window.x < a
  143.       @party_command_window.x += 16
  144.     elsif @actor_command_window.active and @party_command_window.x > b
  145.       @party_command_window.x -= 16
  146.     end
  147.   end
  148.  
  149.   def offset_command_window
  150.     case Z17::BATTLESYSTEM
  151.     when 0; a, b = [544 - @actor_command_window.width, 544]
  152.     when 1; a, b = [672 - @actor_command_window.width, 672]
  153.     end
  154.     if @actor_command_window.active and @actor_command_window.x > a
  155.       @actor_command_window.x -= 16
  156.     elsif (@party_command_window.active or !@skill_window.nil?) and @actor_command_window.x < b
  157.       @actor_command_window.x += 16
  158.     end
  159.   end
  160.  
  161. end
  162.  
  163. class Window_Selectable < Window_Base
  164.   attr_writer :column_max
  165.   attr_writer :spacing
  166. end
  167.  
  168. class Window_BattleStatus < Window_Selectable
  169.  
  170.   alias zreq_initialize initialize
  171.   def initialize
  172.     zreq_initialize
  173.     @column_max = Game_Party::MAX_MEMBERS
  174.   end
  175.  
  176.   def refresh
  177.     self.contents.clear
  178.     @item_max = $game_party.members.size
  179.     create_contents
  180.     for i in 0...@item_max
  181.       draw_item(i)
  182.     end
  183.   end
  184.  
  185.   def draw_item(index)
  186.     rect = Rect.new(index*size_x+4, 0, size_x-8, 96)
  187.     self.contents.clear_rect(rect)
  188.     self.contents.font.color = normal_color
  189.     actor = $game_party.members[index]
  190.     x = rect.x
  191.     y = rect.y
  192.     draw_face_z17(actor, x, y)
  193.     draw_actor_name(actor, x, y-6)
  194.     draw_actor_state(actor, x, y+40, 48)
  195.     draw_actor_hp(actor, x, y+58, size_x-8)
  196.     draw_actor_mp(actor, x, y+74, size_x-8)
  197.   end
  198.  
  199.   def draw_face_z17(actor, x, y)
  200.     if size_x > 96
  201.       ws = (size_x-96) / 2
  202.       draw_actor_face(actor, x+ws, y, 64, 96)
  203.     else
  204.       draw_actor_face(actor, x, y, size_x, 96)
  205.     end
  206.   end
  207.  
  208.   def size_x
  209.     if $game_party.members.size > 4
  210.       return 512 / $game_party.members.size
  211.     else
  212.       return 128
  213.     end
  214.   end
  215.  
  216.   def update_cursor
  217.     if @index < 0
  218.       self.cursor_rect.empty
  219.     else
  220.       rect = Rect.new(index*size_x, 0, size_x, 96)
  221.       self.cursor_rect = rect
  222.     end
  223.   end
  224.  
  225. end
  226.  
  227. class Window_Base < Window
  228.  
  229.   def draw_face(face_name, face_index, x, y, size1 = 96, size2 = 96)
  230.     bitmap = Cache.face(face_name)
  231.     rect = Rect.new(0, 0, 0, 0)
  232.     rect.x = face_index % 4 * 96 + (96 - size2) / 2
  233.     rect.y = face_index / 4 * 96 + (96 - size1) / 2
  234.     rect.width = size2
  235.     rect.height = size1
  236.     self.contents.blt(x, y, bitmap, rect)
  237.     bitmap.dispose
  238.   end
  239.  
  240.   def draw_actor_face(actor, x, y, size1 = 96, size2 = -1)
  241.     size2 = size1 if size2 == -1
  242.     draw_face(actor.face_name, actor.face_index, x, y, size1, size2)
  243.   end
  244.  
  245. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement