Advertisement
Ellye

[VXA] Ellye's Battle Interface

Nov 11th, 2015
1,586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.32 KB | None | 0 0
  1. #-------------------------------------------------------------------
  2. # Ellye's Combat Interface
  3. # A Combat UI script made by Ellye.
  4. # This is a free script for all use, provided "as is", no warranties.
  5. #-------------------------------------------------------------------
  6.  
  7. #--------------------------------------------------------------------------
  8. # * Changes the Maximum number of battle party members to 6
  9. #--------------------------------------------------------------------------
  10. class Game_Party
  11.   def max_battle_members
  12.     return 6
  13.   end
  14. end
  15.  
  16. class Spriteset_Battle
  17.   def create_actors
  18.      @actor_sprites = Array.new(6) { Sprite_Battler.new(@viewport1) }
  19.   end
  20. end
  21.  
  22. #--------------------------------------------------------------------------
  23. # * Uses charset sprites as Actor battlers sprites
  24. #--------------------------------------------------------------------------
  25. class Game_Actor
  26.   attr_accessor :screen_x
  27.   attr_accessor :screen_y              
  28.   attr_accessor :screen_z
  29.  
  30.   alias :old_initialize :initialize
  31.   def initialize(actor_id)
  32.     old_initialize(actor_id)
  33.     @screen_x = 0
  34.     @screen_y = 0
  35.   end
  36.  
  37.   def screen_z
  38.     return 100
  39.   end
  40.  
  41.   def use_sprite?
  42.     return true
  43.   end
  44.  
  45.   alias :old_on_battle_start :on_battle_start
  46.   def on_battle_start
  47.     old_on_battle_start
  48.     @screen_x = 180 + (92 * (self.index % 3))
  49.     self.index < 3 ? @screen_y = 320 : @screen_y = 384
  50.   end
  51.  
  52. end
  53.  
  54. class Sprite_Battler
  55.   def update_bitmap
  56.     char_w = 32
  57.     char_h = 32
  58.    
  59.     if @battler.battler_name == "" && @battler.character_name != ""
  60.       @battler.character_index < 4 ? rect_y = char_h*3 : rect_y = char_h*7 #Selecting correct row for the sprite (Standard size)
  61.       rect_x =  char_w + (char_w*3*(@battler.character_index % 4)) #Selecting correct colunm  for the sprite (Standard size)
  62.       new_bitmap_cs = Cache.character(@battler.character_name) #Load charset
  63.       new_bitmap = Bitmap.new(char_w, char_h) #Make empty, standard character sized, bitmap
  64.       new_bitmap.blt(0, 0, new_bitmap_cs, Rect.new(rect_x, rect_y, char_w, char_h))  #Copies the sprite from the charset to the new bitmap
  65.     else
  66.       new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
  67.     end
  68.    
  69.     if bitmap != new_bitmap
  70.       self.bitmap = new_bitmap
  71.       init_visibility
  72.     end
  73.    
  74.   end
  75.  
  76.   #--------------------------------------------------------------------------
  77.   # * Changing the duration of some effects, and adding a new :pounce effect for physical attacks
  78.   #--------------------------------------------------------------------------
  79.   def start_effect(effect_type)
  80.     @effect_type = effect_type
  81.     case @effect_type
  82.     when :appear
  83.       @effect_duration = 32
  84.       @battler_visible = true
  85.     when :disappear
  86.       @effect_duration = 64
  87.       @battler_visible = false
  88.     when :pounce
  89.       @effect_duration = 32
  90.       @battler_visible = true
  91.     when :whiten
  92.       @effect_duration = 32
  93.       @battler_visible = true
  94.     when :blink
  95.       @effect_duration = 40
  96.       @battler_visible = true
  97.     when :collapse
  98.       @effect_duration = 48
  99.       @battler_visible = false
  100.     when :boss_collapse
  101.       @effect_duration = bitmap.height
  102.       @battler_visible = false
  103.     when :instant_collapse
  104.       @effect_duration = 16
  105.       @battler_visible = false
  106.     end
  107.     revert_to_normal
  108.   end
  109. #--------------------------------------------------------------------------
  110. # * Updating the Pounce Effect
  111. #--------------------------------------------------------------------------
  112.     def update_effect
  113.       if @effect_duration > 0
  114.         @effect_duration -= 1
  115.         case @effect_type
  116.         when :pounce
  117.           update_pounce
  118.         when :whiten
  119.           update_whiten
  120.         when :blink
  121.           update_blink
  122.         when :appear
  123.           update_appear
  124.         when :disappear
  125.           update_disappear
  126.         when :collapse
  127.           update_collapse
  128.         when :boss_collapse
  129.           update_boss_collapse
  130.         when :instant_collapse
  131.           update_instant_collapse
  132.         end
  133.         @effect_type = nil if @effect_duration == 0
  134.       end
  135.     end
  136.  
  137.   def update_pounce
  138.     @effect_duration > 16 ? self.oy += 32 - @effect_duration : self.oy += @effect_duration
  139.   end
  140.  
  141.   alias :old_revert_to_normal :revert_to_normal
  142.   def revert_to_normal
  143.     old_revert_to_normal
  144.     self.oy = bitmap.height
  145.   end
  146.  
  147. end
  148.  
  149. #--------------------------------------------------------------------------
  150. # *  Battle Scene layout
  151. #--------------------------------------------------------------------------
  152. class Scene_Battle
  153.   alias :old_create_status_window :create_status_window
  154.   alias :old_create_info_viewport :create_info_viewport
  155.  
  156.   def create_status_window
  157.     old_create_status_window
  158.     @status_window.x = 137
  159.     @status_window.set_handler(:ok,     method(:on_actor_ok)) #We will use the status window for party-targetting
  160.     @status_window.set_handler(:cancel, method(:on_actor_cancel)) #We will use the status window for party-targetting
  161.   end
  162.  
  163.   def create_info_viewport
  164.     old_create_info_viewport
  165.     @info_viewport.ox = 0
  166.   end
  167.  
  168.   def move_info_viewport(ox)
  169.     current_ox = @info_viewport.ox #don't move anymore
  170.   end
  171.    
  172.   alias :old_create_actor_command_window :create_actor_command_window
  173.   def create_actor_command_window
  174.     old_create_actor_command_window
  175.     @actor_command_window.x = Graphics.width - @actor_command_window.width
  176.   end
  177.  
  178.   def select_actor_selection
  179.     @status_window.refresh
  180.     @status_window.activate #We will use the status window for party-targetting
  181.   end
  182.  
  183.   def on_actor_ok
  184.     BattleManager.actor.input.target_index = @status_window.index #We will use the status window for party-targetting
  185.     @actor_window.hide
  186.     @skill_window.hide
  187.     @item_window.hide
  188.     next_command
  189.   end
  190.  
  191.   def abs_wait_short
  192.     abs_wait(20)
  193.   end
  194.  
  195.   def execute_action
  196.     if @subject.actor?
  197.       @subject.sprite_effect_type = :pounce #changed to the custom pounce effect
  198.     else
  199.       @subject.sprite_effect_type = :whiten #enemies still look better with whiten
  200.     end
  201.     use_item
  202.     abs_wait_short #Slowing things down a bit
  203.     @log_window.wait_and_clear
  204.   end
  205.  
  206. end
  207.  
  208.  #--------------------------------------------------------------------------
  209.  # *  Battle Status Window layout
  210.  #--------------------------------------------------------------------------
  211. class Window_BattleStatus
  212.   def initialize
  213.       super(0, 0, window_width, window_height)
  214.       refresh
  215.       self.openness = 0
  216.       self.opacity = 0
  217.   end
  218.   def window_width
  219.     270
  220.   end
  221.   def window_height
  222.     144
  223.   end
  224.   def col_max
  225.     return 3
  226.   end
  227.   def spacing
  228.     return 6
  229.   end
  230.   def standard_padding
  231.     return 0
  232.   end
  233.   def item_height
  234.     return 48
  235.   end
  236.   def item_rect(index)
  237.       rect = Rect.new
  238.       rect.width = item_width
  239.       rect.height = item_height
  240.       rect.x = index % col_max * (item_width + spacing)
  241.       rect.y = 8 + (index / col_max * (item_height + 16))
  242.       rect
  243.   end
  244.  
  245.   def draw_vertical_actor_icons(actor, x, y, height = 24)
  246.     icons = (actor.state_icons + actor.buff_icons)[0, height / 24]
  247.     icons.each_with_index {|n, i| draw_icon(n, x, y + 24*i) }
  248.   end
  249.  
  250.   def draw_item(index)
  251.     actor = $game_party.battle_members[index]
  252.     rect = item_rect(index)
  253.     draw_actor_hp(actor, rect.x, rect.y+32, rect.width)
  254.     draw_vertical_actor_icons(actor, rect.x, rect.y)
  255.     if $data_system.opt_display_tp
  256.       draw_actor_mp(actor, rect.x, rect.y+48, (rect.width/2)-1)
  257.       draw_actor_tp(actor, rect.x+(rect.width/2)+2, rect.y+48, (rect.width/2)-1)
  258.     else
  259.       draw_actor_mp(actor, rect.x, rect.y+48, rect.width)
  260.     end
  261.   end
  262. end
  263.  
  264. #--------------------------------------------------------------------------
  265. # *  Battle Log - slowing it down a bit
  266. #--------------------------------------------------------------------------
  267. class Window_BattleLog
  268.  
  269.   def display_action_results(target, item)
  270.     if target.result.used
  271.       last_line_number = line_number
  272.       display_critical(target, item)
  273.       display_damage(target, item)
  274.       display_affected_status(target, item)
  275.       display_failure(target, item)
  276.       wait if line_number > last_line_number
  277.     end
  278.   end
  279.  
  280.   def wait_and_clear
  281.     wait while @num_wait < 4 if line_number > 0
  282.     clear
  283.   end
  284.  
  285. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement