IceDragon200

IEO-006(Custom Battle Status)

Apr 17th, 2011
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.83 KB | None | 0 0
  1. #==============================================================================#
  2. # ** CHANGES
  3. #-*--------------------------------------------------------------------------*-#
  4. # Classes
  5. #   Game_BattleAction
  6. #     new-method :battle_vocab
  7. #     new-method :battle_commands
  8. #   Window_ActorCommand
  9. #     new-method :draw_command
  10. #     overwrite  :initialize
  11. #     overwrite  :setup
  12. #     overwrite  :refresh
  13. #     overwrite  :draw_item
  14. #   Scene_Battle
  15. #     overwrite  :execute_action_skill
  16. #
  17. #------------------------------------------------------------------------------#
  18. #==============================================================================#
  19. # $imported - Is mostly used by Japanese RPG Maker XP/VX scripters.
  20. #             This acts as a flag, or signal to show that "x" script is present.
  21. #             This is used for compatability with other future scripts.
  22. $imported = {} if $imported == nil
  23. $imported["IEO-CustomBattleStatus"] = true
  24. #==============================================================================#
  25. # $ieo_script - This is a hash specific to IEO scripts
  26. #               they work just like the $imported, but there key is slightly
  27. #               different, it is an array conatining an integer
  28. #               and a string, since IEO script all have an ID, the value
  29. #               is the scripts version number.
  30. #               A version number of nil, or 0 means the script isn't present
  31. # EG. $ieo_script[[ScriptID, "ScriptName"]]
  32. $ieo_script = {} if $ieo_script == nil
  33. $ieo_script[[6, "CustomBattleStatus"]] = 1.0
  34. #-*--------------------------------------------------------------------------*-#
  35. #==============================================================================#
  36. # Window_BattleStatus
  37. #==============================================================================#
  38. class Window_BattleStatus < Window_Selectable
  39.  
  40.   #--------------------------------------------------------------------------
  41.   # * Object Initialization
  42.   #--------------------------------------------------------------------------
  43.   def initialize
  44.     super(0, 0, (Graphics.width-128), 128) # 128
  45.     @draw_style = 1       # //
  46.     @state_drawstyle = 1  # //
  47.     @spacing = 4
  48.     @members = []
  49.     @state_sprites = []
  50.     @state_drawsizes = []
  51.     @state_viewports = []
  52.     # // This is the scroll speed, icons are 24x24 so setting it to 24 will result
  53.     # // in icon flipping
  54.     @scrolling_speed = 24 #1
  55.     @scrolling_delay = 0
  56.     # // This is the frame delay between scrolling
  57.     @scrolling_delaymax = 3
  58.     # //
  59.     for i in 0...$game_party.members.size
  60.       create_state_sprite(i)
  61.     end  
  62.     self.opacity = 0
  63.     refresh
  64.     self.active = false
  65.   end
  66.  
  67.   def create_state_sprite(index)
  68.     rect = item_rect(index)
  69.     @state_viewports[index] = Viewport.new(rect.x + 96 - 24, rect.y + 96 - 24,
  70.       24, 24)
  71.     @state_sprites[index] = Plane.new(@state_viewports[index])
  72.     @state_sprites[index].bitmap = Bitmap.new(24*16, 24)
  73.     update_state
  74.   end
  75.  
  76.   #--------------------------------------------------------------------------#
  77.   # * overwrite method :refresh
  78.   #--------------------------------------------------------------------------#
  79.   def refresh
  80.     case @draw_style
  81.     when 0 ; self.width = (Graphics.width-128)
  82.     when 1 ; self.width = (Graphics.width-96)      
  83.     end  
  84.     create_contents
  85.     @members  = $game_party.members
  86.     @item_max = @members.size
  87.     setup_column_max
  88.     for i in 0...@item_max
  89.       draw_item(i)
  90.     end
  91.   end
  92.  
  93.   #--------------------------------------------------------------------------#
  94.   # * new method :setup_column_max
  95.   #--------------------------------------------------------------------------#  
  96.   def setup_column_max
  97.     case @draw_style
  98.     when 0
  99.       @column_max = 2
  100.     when 1  
  101.       @column_max = @item_max
  102.     end
  103.   end  
  104.  
  105.   #--------------------------------------------------------------------------#
  106.   # * overwrite method :item_rect
  107.   #--------------------------------------------------------------------------#
  108.   def item_rect(index)
  109.     rect = Rect.new(0, 0, 0, 0)
  110.     case @draw_style
  111.     when 0
  112.       rect.width = (contents.width + @spacing) / @column_max - @spacing
  113.       rect.height = WLH*2
  114.       rect.x = index % @column_max * (rect.width + @spacing)
  115.       rect.y = index / @column_max * WLH*2
  116.     when 1  
  117.       rect.width = 96 + 32
  118.       rect.height = 96
  119.       rect.x = index % @column_max * (rect.width + @spacing)
  120.       rect.y = index / @column_max * WLH*2
  121.     end
  122.     return rect
  123.   end
  124.  
  125.   #--------------------------------------------------------------------------#
  126.   # * overwrite method :draw_item
  127.   #--------------------------------------------------------------------------#
  128.   def draw_item(index)
  129.     rect = item_rect(index)
  130.     rect.x += 4
  131.     rect.width -= 8
  132.     self.contents.clear_rect(rect)
  133.     self.contents.font.color = normal_color
  134.     actor = @members[index]
  135.    
  136.     case @draw_style
  137.     when 0
  138.       otrect = Rect.new(rect.x+2, rect.y+2, rect.height-4, rect.height-4)
  139.       draw_outlined_actor(actor, otrect, 2, Color.new(0, 0, 0, 96))
  140.       trect = Rect.new(otrect.x+otrect.width+32, rect.y+2, rect.width, 24)
  141.       draw_icon(IEO::Icon.battle_action(actor, actor.action), trect.x-28, rect.y, actor.action.valid?)
  142.       self.contents.font.size = 16
  143.       draw_actor_name(actor, rect.x, rect.y+rect.height-24)
  144.       draw_states(index, actor, trect)
  145.       draw_actor_hp_gauge(actor, trect.x-24, trect.y+8, 96)
  146.       draw_actor_mp_gauge(actor, trect.x-12, trect.y+20, 96)
  147.       self.contents.font.size = 12
  148.       self.contents.draw_text(trect.x, trect.y+12, 120, 24,
  149.         sprintf("%s/%s", actor.hp, actor.maxhp) )
  150.       self.contents.draw_text(trect.x+12, trect.y+24, 120, 24,
  151.         sprintf("%s/%s", actor.mp, actor.maxmp) )  
  152.       #draw_actor_hp(actor, trect.x, trect.y+24, 120)
  153.       #draw_actor_mp(actor, 310, rect.y, 70)
  154.     when 1  
  155.       self.contents.font.size = 16
  156.       draw_actor_face(actor, rect.x, rect.y)
  157.       draw_actor_name(actor, rect.x, rect.y)
  158.       #draw_actor_state(actor, rect.x, rect.y+96-24, 96)
  159.       trect = rect.clone ; trect.y += 96-24
  160.       draw_states(index, actor, trect)
  161.       brect = rect.clone
  162.       brect.x += rect.width - 24
  163.       brect.width = 12
  164.       brect.y += 16
  165.       brect.height -= 16
  166.      
  167.       # // HP
  168.       draw_vertical_grad_bar(brect, actor.hp, actor.maxhp,
  169.         hp_gauge_color1, hp_gauge_color2, Color.new(20, 20, 20),
  170.         2, false, true)
  171.       # //
  172.       self.contents.font.size = 16
  173.       self.contents.draw_text(brect.x, brect.y-16, 24, 24, Vocab.hp_a)
  174.       brect.x += 14
  175.       # // MP
  176.       draw_vertical_grad_bar(brect, actor.mp, actor.maxmp,
  177.         mp_gauge_color1, mp_gauge_color2, Color.new(20, 20, 20),
  178.         2, false, true)  
  179.       # //
  180.       self.contents.font.size = 16
  181.       self.contents.draw_text(brect.x, brect.y-16, 24, 24, Vocab.mp_a)
  182.     end
  183.  
  184.   end
  185.  
  186.   #--------------------------------------------------------------------------#
  187.   # * new method :draw_states
  188.   #--------------------------------------------------------------------------#
  189.   def draw_states(index, actor, rect)
  190.     case @state_drawstyle
  191.     when 0
  192.       draw_actor_state(actor, rect.x, rect.y, 96)
  193.     when 1
  194.       c = 0
  195.       @state_drawsizes[index] = actor.states.size
  196.       @state_sprites[index].bitmap.dispose
  197.       @state_sprites[index].bitmap = Bitmap.new([24*@state_drawsizes[index], 24].max, 24)
  198.       for st in actor.states
  199.         @state_sprites[index].bitmap.draw_icon(st.icon_index, c*24, 0) ; c += 1
  200.       end
  201.     end  
  202.   end  
  203.  
  204.   #--------------------------------------------------------------------------#
  205.   # * alias method :dispose
  206.   #--------------------------------------------------------------------------#  
  207.   alias ieo006_dispose dispose unless $@
  208.   def dispose
  209.     ieo006_dispose
  210.     for sp in @state_sprites.compact ; sp.dispose end
  211.   end
  212.  
  213.   #--------------------------------------------------------------------------#
  214.   # * alias method :update
  215.   #--------------------------------------------------------------------------#  
  216.   alias ieo006_update update unless $@
  217.   def update
  218.     ieo006_update
  219.     update_state
  220.   end
  221.  
  222.   #--------------------------------------------------------------------------#
  223.   # * alias method :update_state
  224.   #--------------------------------------------------------------------------#  
  225.   def update_state
  226.     @scrolling_delay -= 1
  227.     for i in 0...@state_sprites.size
  228.       rect = item_rect(i)
  229.       st = @state_sprites[i]
  230.       vis2 = true ; vis2 = self.viewport.visible unless self.viewport.nil?
  231.       st.visible = (self.visible && vis2)
  232.       if st.bitmap.width > 24 ; st.ox += @scrolling_speed
  233.       else ; st.ox = 0 ; end if @scrolling_delay <= 0
  234.       dx, dy = 0, 0
  235.       unless self.viewport.nil?
  236.         dx, dy = self.viewport.rect.x, self.viewport.rect.y
  237.         dx -= self.viewport.ox
  238.         dy -= self.viewport.oy
  239.       end  
  240.       @state_viewports[i].rect.set(
  241.         dx+ self.x + rect.x + 96-4, dy + self.y + rect.y + 96-4,
  242.         24, 24)
  243.       @state_viewports[i].z = self.z
  244.       @state_viewports[i].update
  245.     end
  246.     if Input.trigger?(Input::F6)
  247.       rec = @state_viewports[0].rect
  248.       [self.viewport.rect.x, self.viewport.rect.y].each { |sx| print sx }
  249.       [self.viewport.ox, self.viewport.oy].each { |sx| print sx }
  250.       #[self.x, self.y].each { |sx| print sx }
  251.       [rec.x, rec.y].each   { |xc| print xc }
  252.     end  
  253.     @scrolling_delay = @scrolling_delaymax if @scrolling_delay <= 0
  254.   end
  255.  
  256. end
  257.  
  258. #==============================================================================#
  259. # Scene_Battle
  260. #==============================================================================#
  261. class Scene_Battle < Scene_Base
  262.  
  263.   alias ieo006_start_party_command_selection start_party_command_selection unless $@
  264.   def start_party_command_selection
  265.     ieo006_start_party_command_selection
  266.     @status_window.refresh
  267.   end
  268.  
  269. #~   alias ieo006_end_item_selection end_item_selection unless $@
  270. #~   def end_item_selection
  271. #~     ieo006_end_item_selection
  272. #~     @status_window.refresh
  273. #~   end
  274. #~  
  275. #~   alias ieo006_end_skill_selection end_skill_selection unless $@
  276. #~   def end_skill_selection
  277. #~     ieo006_end_skill_selection
  278. #~     @status_window.refresh
  279. #~   end
  280. #~  
  281. #~   alias ieo006_end_target_enemy_selection end_target_enemy_selection unless $@
  282. #~   def end_target_enemy_selection
  283. #~     ieo006_end_target_enemy_selection
  284. #~     @status_window.refresh
  285. #~   end
  286. #~  
  287. #~   alias ieo006_end_target_actor_selection end_target_actor_selection unless $@
  288. #~   def end_target_actor_selection
  289. #~     ieo006_end_target_actor_selection
  290. #~     @status_window.refresh
  291. #~   end
  292.  
  293.   alias ieo006_next_actor next_actor unless $@
  294.   def next_actor
  295.     ieo006_next_actor
  296.     @status_window.refresh
  297.   end
  298.  
  299. end
Advertisement
Add Comment
Please, Sign In to add comment