Advertisement
Raizen

Akea Animated Battle Cursor(English)

Mar 9th, 2015
1,347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.59 KB | None | 0 0
  1. #=======================================================
  2. #        Akea Animated Battle Cursor
  3. # Author: Raizen
  4. # Community: http://www.centrorpg.com/
  5. # Compatibility: RMVXAce
  6. #
  7. #=======================================================
  8. # =========================Don't Modify==============================
  9. $included ||= Hash.new
  10. $included[:akea_battlecursor] = true
  11. module Akea_BattleCursor
  12. # =========================Don't Modify==============================
  13.  
  14. # Configuration starts Here
  15.  
  16. #=======================================================
  17. #        INSTRUCTIONS
  18. # Simple, put the script above main and below any other battle scripts
  19. # (for better compatibility)
  20. # And then configure below, the scripts shows an animated battle cursor.
  21. #=======================================================
  22.  
  23. # If animated, this is the framerate update of the animation, the higher the slower.
  24. Cursor_Update = 10
  25.  
  26. # Show the default windows that identify the enemies and actors?
  27. Show_Windows = false
  28.  
  29. # Show battler names?
  30. Show_Name = true
  31.  
  32. # Name of fot, put '' to be used default font
  33. Font_Name = 'Georgia'
  34.  
  35. # Size of font, put 0 to use default font size
  36. Font_Size = 18
  37.  
  38. #==============================================================================
  39. # ** Enemy Configuration
  40. #==============================================================================
  41.  
  42. # Font Color for Enemies, following the default R, G, B and on the end put the
  43. # opacity of the font, being 0 invisible until 255 full visible
  44. Enemy_Font_Color = [255, 100, 100, 255]
  45.  
  46. # Name of cursor image, must be in the folder Graphics/Akea
  47. Enemy_Cursor = 'Enemy_Cursor'
  48.  
  49. # Number of frames the enemy cursor has, if not animated put
  50. # Enemy_Frames = 1
  51. Enemy_Frames = 5
  52.  
  53. # Cursor position over the enemies
  54. # E_Cursor_Position = [x position, y position]
  55. E_Cursor_Position = [0, -70]
  56.  
  57. # Position of enemy name
  58. # E_Name_Position = [x position, y position]
  59. E_Name_Position = [0, -30]
  60.  
  61. # Name of cursor image, must be in the folder Graphics/Akea
  62. # In case you do not use visible actors, put
  63. # Actor_Cursor = ''
  64. Actor_Cursor = 'Actor_Cursor'
  65. #==============================================================================
  66. # ** Actor configuration
  67. # Not necessary IF you do not use visible actors
  68. #==============================================================================
  69.  
  70. # Font color for the actors, following the default R, G, B and on the end put the
  71. # opacity of the font, being 0 invisible until 255 full visible
  72. Actor_Font_Color = [100, 255, 150, 255]
  73.  
  74. # Numver of frames from the actor cursor, if not animated put
  75. # Actor_Frames = 1
  76. Actor_Frames = 5
  77.  
  78. # Cursor Position over the actors
  79. # A_Cursor_Position = [x position, y position]
  80. A_Cursor_Position = [-55, -70]
  81. #
  82. # Name position of the actors
  83. # A_Name_Position = [x position, y position]
  84. A_Name_Position = [-10, -10]
  85.  
  86.  
  87. #==============================================================================
  88. # ** HERE starts the script
  89. #==============================================================================
  90.  
  91. end
  92.  
  93. #==============================================================================
  94. # ** Scene_Battle
  95. #------------------------------------------------------------------------------
  96. #  Esta classe executa o processamento da tela de batalha.
  97. #==============================================================================
  98.  
  99. class Scene_Battle < Scene_Base
  100. alias :akea_bc_start :start
  101. alias :akea_bc_update :update
  102. alias :akea_bc_select_enemy_selection :select_enemy_selection
  103. alias :akea_bc_on_skill_ok :on_skill_ok
  104. alias :akea_bc_on_enemy_cancel :on_enemy_cancel
  105. alias :akea_bc_on_item_ok :on_item_ok
  106. alias :akea_bc_on_actor_cancel :on_actor_cancel
  107. alias :akea_bc_select_actor_selection :select_actor_selection
  108. alias :akea_bc_terminate :terminate
  109. alias :akea_bc_turn_start :turn_start
  110. alias :akea_bc_next_command :next_command
  111.   #--------------------------------------------------------------------------
  112.   # * Inicialização do processo
  113.   #--------------------------------------------------------------------------
  114.   def start
  115.     @bc_cursor = Array.new
  116.     @bc_enemy_cursor = Array.new
  117.     @bc_actor_cursor = Array.new
  118.     @akea_target_all = false
  119.     akea_bc_start
  120.     akea_bc_create_pictures
  121.   end
  122.   def akea_bc_create_pictures
  123.     @bc_actor_size = $game_party.battle_members.size
  124.     @bc_frame_position = 0
  125.     for n in 0...all_battle_members.size
  126.       next unless all_battle_members[n].use_sprite?
  127.       @bc_cursor[n] = Sprite.new
  128.       @bc_cursor[n].bitmap = Bitmap.new(Graphics.width, Graphics.height)
  129.       #@bc[n].bitmap.font.size = 48
  130.       rect = Rect.new(0, 0, 200, 50)
  131.       if all_battle_members[n].actor?
  132.         @bc_cursor[n].bitmap.font.color = Color.new(Akea_BattleCursor::Actor_Font_Color[0], Akea_BattleCursor::Actor_Font_Color[1], Akea_BattleCursor::Actor_Font_Color[2], Akea_BattleCursor::Actor_Font_Color[3])
  133.         @bc_actor_cursor[n] = Sprite.new
  134.         @bc_actor_cursor[n].bitmap = Cache.akea(Akea_BattleCursor::Actor_Cursor)
  135.         @bc_actor_cursor[n].src_rect.set(0, 0, @bc_actor_cursor[n].bitmap.width/Akea_BattleCursor::Actor_Frames, @bc_actor_cursor[n].bitmap.height)
  136.         @bc_actor_cursor[n].opacity = 0
  137.       else
  138.         @bc_enemy_cursor << Sprite.new
  139.         @bc_enemy_cursor.last.bitmap = Cache.akea(Akea_BattleCursor::Enemy_Cursor)
  140.         @bc_enemy_cursor.last.src_rect.set(0, 0, @bc_enemy_cursor.last.bitmap.width/Akea_BattleCursor::Enemy_Frames, @bc_enemy_cursor.last.bitmap.height)
  141.         @bc_enemy_cursor.last.opacity = 0
  142.         @bc_cursor[n].bitmap.font.color = Color.new(Akea_BattleCursor::Enemy_Font_Color[0], Akea_BattleCursor::Enemy_Font_Color[1], Akea_BattleCursor::Enemy_Font_Color[2], Akea_BattleCursor::Enemy_Font_Color[3])
  143.       end
  144.       @bc_cursor[n].bitmap.font.size = Akea_BattleCursor::Font_Size unless Akea_BattleCursor::Font_Size == 0
  145.       @bc_cursor[n].bitmap.font.name = Akea_BattleCursor::Font_Name unless Akea_BattleCursor::Font_Name == ''
  146.       @bc_cursor[n].bitmap.draw_text(rect, all_battle_members[n].name, 0) if Akea_BattleCursor::Show_Name
  147.       @bc_cursor[n].z = 105
  148.       if all_battle_members[n].enemy?
  149.         @bc_cursor[n].x = all_battle_members[n].screen_x + Akea_BattleCursor::E_Name_Position[0]
  150.         @bc_cursor[n].y = all_battle_members[n].screen_y + Akea_BattleCursor::E_Name_Position[1]
  151.       else
  152.         @bc_cursor[n].x = all_battle_members[n].screen_x + Akea_BattleCursor::A_Name_Position[0]
  153.         @bc_cursor[n].y = all_battle_members[n].screen_y + Akea_BattleCursor::A_Name_Position[1]
  154.       end
  155.       @bc_cursor[n].opacity = 0
  156.     end
  157.   end
  158.   def update(*args, &block)
  159.     akea_bc_update
  160.     show_bc_info
  161.   end
  162.   def show_bc_info
  163.     if @enemy_window.active
  164.       @bc_enemy_cursor.each{|cursor| cursor.opacity -= 30}
  165.       @bc_actor_cursor.each{|cursor| cursor.opacity -= 30}
  166.       @bc_cursor.each{|cursor| cursor.opacity -= 30}
  167.       if @akea_target_all
  168.         for n in 0...@bc_enemy_cursor.size
  169.           if $game_troop.members[n].alive?
  170.             @bc_cursor[n + $game_party.members.size].opacity += 60
  171.             @bc_enemy_cursor[n].x = $game_troop.members[n].screen_x + Akea_BattleCursor::E_Cursor_Position[0]
  172.             @bc_enemy_cursor[n].y = $game_troop.members[n].screen_y + Akea_BattleCursor::E_Cursor_Position[1]
  173.             @bc_enemy_cursor[n].opacity += 60
  174.           end
  175.         end
  176.       else
  177.         @bc_enemy_cursor[@enemy_window.enemy.index].x = $game_troop.members[@enemy_window.enemy.index].screen_x + Akea_BattleCursor::E_Cursor_Position[0]
  178.         @bc_enemy_cursor[@enemy_window.enemy.index].y = $game_troop.members[@enemy_window.enemy.index].screen_y + Akea_BattleCursor::E_Cursor_Position[1]
  179.         @bc_enemy_cursor[@enemy_window.enemy.index].opacity += 60
  180.         @bc_cursor[@enemy_window.enemy.index + $game_party.members.size].opacity += 60
  181.       end
  182.       update_bc_enemy_cursor
  183.     elsif @actor_window.active
  184.       if all_battle_members[0].use_sprite?
  185.         @bc_enemy_cursor.each{|cursor| cursor.opacity -= 30}
  186.         @bc_actor_cursor.each{|cursor| cursor.opacity -= 30}
  187.         @bc_cursor.each{|cursor| cursor.opacity -= 30}
  188.         if @akea_target_all
  189.           for n in 0...@bc_actor_cursor.size
  190.             @bc_actor_cursor[n].x = all_battle_members[n].screen_x + Akea_BattleCursor::A_Cursor_Position[0]
  191.             @bc_actor_cursor[n].y = all_battle_members[n].screen_y + Akea_BattleCursor::A_Cursor_Position[1]
  192.             @bc_actor_cursor[n].opacity += 60
  193.             @bc_cursor[n].opacity += 60
  194.           end
  195.         else
  196.           @bc_actor_cursor[@actor_window.index].x = all_battle_members[@actor_window.index].screen_x + Akea_BattleCursor::A_Cursor_Position[0]
  197.           @bc_actor_cursor[@actor_window.index].y = all_battle_members[@actor_window.index].screen_y + Akea_BattleCursor::A_Cursor_Position[1]
  198.           @bc_actor_cursor[@actor_window.index].opacity += 60
  199.           @bc_cursor[@actor_window.index].opacity += 60
  200.         end
  201.       end
  202.       update_bc_actor_cursor
  203.     else
  204.       for n in 0...all_battle_members.size
  205.         next unless all_battle_members[n].use_sprite?
  206.         @bc_cursor[n].opacity -= 30
  207.       end
  208.         @bc_enemy_cursor.each{|cursor| cursor.opacity -= 30}
  209.         @bc_actor_cursor.each{|cursor| cursor.opacity -= 30}
  210.     end
  211.   end
  212.   def update_bc_enemy_cursor
  213.     return unless Graphics.frame_count % Akea_BattleCursor::Cursor_Update == 0
  214.     if @bc_frame_position >= Akea_BattleCursor::Enemy_Frames - 1
  215.       @bc_frame_position = 0
  216.     else
  217.       @bc_frame_position += 1
  218.     end
  219.     @bc_enemy_cursor.each{|cursor| cursor.src_rect.set(@bc_frame_position*@bc_enemy_cursor[0].bitmap.width/Akea_BattleCursor::Enemy_Frames, 0, @bc_enemy_cursor[0].bitmap.width/Akea_BattleCursor::Enemy_Frames, @bc_enemy_cursor[0].bitmap.height)}
  220.   end
  221.   def update_bc_actor_cursor
  222.     return unless Graphics.frame_count % Akea_BattleCursor::Cursor_Update == 0
  223.     if @bc_frame_position >= Akea_BattleCursor::Actor_Frames - 1
  224.       @bc_frame_position = 0
  225.     else
  226.       @bc_frame_position += 1
  227.     end
  228.     @bc_actor_cursor.each {|cursor| cursor.src_rect.set(@bc_frame_position*@bc_actor_cursor[0].bitmap.width/Akea_BattleCursor::Actor_Frames, 0, @bc_actor_cursor[0].bitmap.width/Akea_BattleCursor::Actor_Frames, @bc_actor_cursor[0].bitmap.height)}
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Início do turno
  232.   #--------------------------------------------------------------------------
  233.   def turn_start
  234.     for n in 0...all_battle_members.size
  235.       next unless all_battle_members[n].use_sprite?
  236.       @bc_cursor[n].opacity = 0
  237.     end
  238.     @bc_enemy_cursor.each{|cursor| cursor.opacity = 0}
  239.     @bc_actor_cursor.each{|cursor| cursor.opacity = 0}
  240.     akea_bc_turn_start
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Seleção da escolha de inimigos
  244.   #--------------------------------------------------------------------------
  245.   def select_enemy_selection
  246.     akea_bc_select_enemy_selection
  247.     @enemy_window.hide unless Akea_BattleCursor::Show_Windows
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # * Seleção da escolha de heróis
  251.   #--------------------------------------------------------------------------
  252.   def select_actor_selection
  253.     akea_bc_select_actor_selection
  254.     @actor_window.hide if all_battle_members[0].use_sprite? && !Akea_BattleCursor::Show_Windows
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # * Habilidade [Confirmação]
  258.   #--------------------------------------------------------------------------
  259.   def on_skill_ok
  260.     @force_window = true
  261.     akea_bc_on_skill_ok
  262.     @force_window = false
  263.     if @skill.for_opponent?
  264.       @skill_window.hide
  265.     else
  266.       @skill_window.hide if all_battle_members[0].use_sprite?
  267.     end
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # * Entrada de comandos para o próximo herói
  271.   #--------------------------------------------------------------------------
  272.   def next_command
  273.     if @force_window && @skill.for_opponent?
  274.         @akea_target_all = true
  275.         select_enemy_selection
  276.       elsif @force_window
  277.         @akea_target_all = true
  278.         select_actor_selection
  279.       else
  280.         @akea_target_all = false
  281.         akea_bc_next_command
  282.     end
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # * Inimigo [Cancelamento]
  286.   #--------------------------------------------------------------------------
  287.   def on_enemy_cancel
  288.     akea_bc_on_enemy_cancel
  289.     @akea_target_all = false
  290.     case @actor_command_window.current_symbol
  291.     when :skill
  292.       @skill_window.show.activate
  293.     when :item
  294.       @item_window.show.activate
  295.     end
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * Herói [Cancelamento]
  299.   #--------------------------------------------------------------------------
  300.   def on_actor_cancel
  301.     akea_bc_on_actor_cancel
  302.     @akea_target_all = false
  303.     case @actor_command_window.current_symbol
  304.     when :skill
  305.       @skill_window.show.activate
  306.     when :item
  307.       @item_window.show.activate
  308.     end
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # * Item [Confirmação]
  312.   #--------------------------------------------------------------------------
  313.   def on_item_ok
  314.     akea_bc_on_item_ok
  315.     if @item.for_opponent?
  316.       @item_window.hide
  317.     else
  318.       @item_window.hide if all_battle_members[0].use_sprite?
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # * Finalização do processo
  323.   #--------------------------------------------------------------------------
  324.   def terminate
  325.     for n in 0...all_battle_members.size
  326.       next unless all_battle_members[n].use_sprite?
  327.       @bc_cursor[n].bitmap.dispose
  328.       @bc_cursor[n].dispose
  329.     end
  330.     @bc_actor_cursor.each{|cursor| cursor.bitmap.dispose}
  331.     @bc_actor_cursor.each{|cursor| cursor.dispose}
  332.     @bc_enemy_cursor.each{|cursor| cursor.bitmap.dispose}
  333.     @bc_enemy_cursor.each{|cursor| cursor.dispose}
  334.     akea_bc_terminate
  335.   end
  336. end
  337.  
  338. #==============================================================================
  339. # ** Cache
  340. #------------------------------------------------------------------------------
  341. #  Este modulo carrega cada gráfico, cria um objeto de Bitmap e retém ele.
  342. # Para acelerar o carregamento e preservar memória, este módulo matém o
  343. # objeto de Bitmap em uma Hash interna, permitindo que retorne objetos
  344. # pré-existentes quando mesmo Bitmap é requerido novamente.
  345. #==============================================================================
  346.  
  347.  
  348. module Cache
  349.   #--------------------------------------------------------------------------
  350.   # * Carregamento dos gráficos de animação
  351.   #     filename : nome do arquivo
  352.   #     hue      : informações da alteração de tonalidade
  353.   #--------------------------------------------------------------------------
  354.   def self.akea(filename)
  355.     load_bitmap("Graphics/Akea/", filename)
  356.   end
  357. end
  358.  
  359.  
  360.  
  361. #==============================================================================
  362. # ** Window_BattleActor
  363. #------------------------------------------------------------------------------
  364. #  Esta janela para seleção de heróis na tela de batalha.
  365. #==============================================================================
  366.  
  367. class Window_BattleActor < Window_BattleStatus
  368.   #--------------------------------------------------------------------------
  369.   # * Movimento do cursor para baixo
  370.   #     wrap : cursor retornar a primeira ou ultima posição
  371.   #--------------------------------------------------------------------------
  372.   def cursor_down(wrap = false)
  373.     super(true)
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # * Movimento do cursor para cima
  377.   #     wrap : cursor retornar a primeira ou ultima posição
  378.   #--------------------------------------------------------------------------
  379.   def cursor_up(wrap = false)
  380.     super(true)
  381.   end
  382.   #--------------------------------------------------------------------------
  383.   # * Movimento do cursor para direita
  384.   #     wrap : cursor retornar a primeira ou ultima posição
  385.   #--------------------------------------------------------------------------
  386.   def cursor_right(wrap = false)
  387.     cursor_down
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # * Movimento do cursor para esquerda
  391.   #     wrap : cursor retornar a primeira ou ultima posição
  392.   #--------------------------------------------------------------------------
  393.   def cursor_left(wrap = false)
  394.     cursor_up
  395.   end
  396. end
  397. #==============================================================================
  398. # ** Window_BattleEnemy
  399. #------------------------------------------------------------------------------
  400. #  Esta janela para seleção de inimigos na tela de batalha.
  401. #==============================================================================
  402.  
  403. class Window_BattleEnemy < Window_Selectable
  404.   #--------------------------------------------------------------------------
  405.   # * Aquisição do número de colunas
  406.   #--------------------------------------------------------------------------
  407.   def col_max
  408.     if Akea_BattleCursor::Show_Windows
  409.       return 2
  410.     else
  411.       return 1
  412.     end
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # * Movimento do cursor para baixo
  416.   #     wrap : cursor retornar a primeira ou ultima posição
  417.   #--------------------------------------------------------------------------
  418.   def cursor_down(wrap = false)
  419.     super(true)
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   # * Movimento do cursor para cima
  423.   #     wrap : cursor retornar a primeira ou ultima posição
  424.   #--------------------------------------------------------------------------
  425.   def cursor_up(wrap = false)
  426.     super(true)
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # * Movimento do cursor para direita
  430.   #     wrap : cursor retornar a primeira ou ultima posição
  431.   #--------------------------------------------------------------------------
  432.   def cursor_right(wrap = false)
  433.     cursor_down
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # * Movimento do cursor para esquerda
  437.   #     wrap : cursor retornar a primeira ou ultima posição
  438.   #--------------------------------------------------------------------------
  439.   def cursor_left(wrap = false)
  440.     cursor_up
  441.   end
  442. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement