Advertisement
Raizen

Akea Toggle Cursor

Mar 12th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.92 KB | None | 0 0
  1. #=======================================================
  2. #        Akea Toggle Target
  3. # Autor: Raizen
  4. # Comunidade: http://www.centrorpg.com/
  5. # Compatibilidade: RMVXAce
  6. #
  7. #=======================================================
  8. # =========================Não modificar==============================
  9. # Funcionalidade:
  10. # O Script permite target toggle na batalha, target toggle são skills
  11. # que podem ser ativados para serem usados em vários inimigos ao invés de um,
  12. # ou/e skills que podem ser usado tanto em aliados quanto em inimigos.
  13. # ----------------------- Não modificar -------------------------
  14. $imported ||= Hash.new
  15. $imported[:akea_toggletarget] = true
  16. module Akea_Toggle_Target
  17. # ----------------------- Aqui começa a configuração -------------------------
  18. # Teclas que ativam o toggle para vários alvos
  19. # Podem haver mais de um, basta separar por vírgulas Ex: [:L, :X, :Q]
  20. # Mapeamento de teclas do RPG Maker
  21. # X = Tecla A  ;  Y = Tecla S  ;  Z = Tecla D
  22. # L = Tecla Q  ;  R = Tecla W  ;  SHIFT
  23. Toggle_Input = [:L]
  24.  
  25. #Teclas que ativam a troca de lado do cursor
  26. # Podem haver mais de um, basta separar por vírgulas Ex: [:L, :X, :Q]
  27. Change_Input = [:R]
  28.  
  29. # Coloque o abaixo no bloco de notas de cada skill que desejar
  30. # <can_toggle>
  31. # Permite que uma skill possa realizar o toggle para todos os alvos
  32.  
  33. # <change_toggle_side>
  34. # Permite que uma skill possa ser usada ambos em inimigos como aliados
  35.  
  36. # <toggle_split n>
  37. # Coloque isso para que o skill tenha divisão de dano caso esteja no
  38. # modo Toggle, n é a % de dano base para o skill, por exemplo
  39. # <toggle_split 100>
  40. # Para 2 inimigos significa 50% de dano em cada um.
  41.  
  42.  
  43.  
  44. end
  45. # =========================Não modificar==============================
  46.  
  47. #==============================================================================
  48. # ** Scene_Battle
  49. #------------------------------------------------------------------------------
  50. #  Esta classe executa o processamento da tela de batalha.
  51. #==============================================================================
  52.  
  53. class Scene_Battle < Scene_Base
  54. alias :akea_tt_update_basic :update_basic
  55. alias :akea_tt_on_skill_ok :on_skill_ok
  56. alias :akea_tt_on_enemy_cancel :on_enemy_cancel
  57. alias :akea_tt_on_actor_cancel :on_actor_cancel
  58.   #--------------------------------------------------------------------------
  59.   # * Atualização da tela (básico)
  60.   #--------------------------------------------------------------------------
  61.   def update_basic
  62.     akea_tt_update_basic
  63.     if @enemy_window.active
  64.       Akea_Toggle_Target::Toggle_Input.each{|input| change_toggle_enemy if Input.trigger?(input)}
  65.       Akea_Toggle_Target::Change_Input.each{|input| change_input_enemy if Input.trigger?(input)}
  66.     elsif @actor_window.active
  67.       Akea_Toggle_Target::Toggle_Input.each{|input| change_toggle_actor if Input.trigger?(input)}
  68.       Akea_Toggle_Target::Change_Input.each{|input| change_input_actor if Input.trigger?(input)}
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Ativar Toggle(Actor)
  73.   #--------------------------------------------------------------------------
  74.   def change_toggle_actor
  75.     return unless BattleManager.actor.current_action.item.note.include?("<can_toggle>")
  76.     @actor_window.set_rect_cursor
  77.     BattleManager.actor.current_action.akea_toggle = @actor_window.cursor_set_all
  78.     @akea_target_all = BattleManager.actor.current_action.akea_toggle
  79.     Sound.play_cursor
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Mudança de Alvo(Para Inimigos)
  83.   #--------------------------------------------------------------------------
  84.   def change_input_actor
  85.     return unless BattleManager.actor.current_action.item.note.include?("<change_toggle_side>")
  86.     #BattleManager.actor.current_action.akea_toggle = false
  87.     #@akea_target_all = false
  88.     BattleManager.actor.current_action.cursor_opposit_set = !BattleManager.actor.current_action.item.for_opponent?
  89.     @actor_window.hide
  90.     @actor_window.deactivate
  91.     @skill_window.deactivate
  92.     Sound.play_cursor
  93.     select_enemy_selection
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # * Ativar Toggle(Enemy)
  97.   #--------------------------------------------------------------------------
  98.   def change_toggle_enemy
  99.     return unless BattleManager.actor.current_action.item.note.include?("<can_toggle>")
  100.     @enemy_window.set_rect_cursor
  101.     BattleManager.actor.current_action.akea_toggle = @enemy_window.cursor_set_all
  102.     @akea_target_all = BattleManager.actor.current_action.akea_toggle
  103.     Sound.play_cursor
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # * Mudança de Alvo(Para Personagens)
  107.   #--------------------------------------------------------------------------
  108.   def change_input_enemy
  109.     return unless BattleManager.actor.current_action.item.note.include?("<change_toggle_side>")
  110.     #BattleManager.actor.current_action.akea_toggle = false
  111.     #@akea_target_all = false
  112.     BattleManager.actor.current_action.cursor_opposit_set = BattleManager.actor.current_action.item.for_opponent?
  113.     @enemy_window.hide
  114.     @enemy_window.deactivate
  115.     @skill_window.deactivate
  116.     Sound.play_cursor
  117.     select_actor_selection
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * Habilidade [Confirmação]
  121.   #--------------------------------------------------------------------------
  122.   def on_skill_ok
  123.     akea_tt_on_skill_ok
  124.     BattleManager.actor.current_action.akea_toggle = false
  125.     BattleManager.actor.current_action.cursor_opposit_set = false
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # * Tela Inimigos [Cancelamento]
  129.   #--------------------------------------------------------------------------
  130.   def on_enemy_cancel
  131.     akea_tt_on_enemy_cancel
  132.     BattleManager.actor.current_action.akea_toggle = false
  133.     BattleManager.actor.current_action.cursor_opposit_set = false
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Tela Persnagens [Cancelamento]
  137.   #--------------------------------------------------------------------------
  138.   def on_actor_cancel
  139.     akea_tt_on_actor_cancel
  140.     @actor_command_window.activate if @actor_command_window.current_symbol == :attack
  141.     BattleManager.actor.current_action.akea_toggle = false
  142.     BattleManager.actor.current_action.cursor_opposit_set = false
  143.   end
  144. end
  145.  
  146.  
  147. #==============================================================================
  148. # ** Window_BattleEnemy
  149. #------------------------------------------------------------------------------
  150. #  Esta janela para seleção de inimigos na tela de batalha.
  151. #==============================================================================
  152.  
  153. class Window_BattleEnemy < Window_Selectable
  154. alias :akea_tt_item_rect :item_rect
  155. attr_reader :cursor_set_all
  156.   #--------------------------------------------------------------------------
  157.   # * Ativar a Janela
  158.   #--------------------------------------------------------------------------
  159.   def activate
  160.     @cursor_set_all = false
  161.     super
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Selecionar o cursor
  165.   #--------------------------------------------------------------------------
  166.   def set_rect_cursor
  167.     @cursor_set_all = !@cursor_set_all
  168.     update_cursor
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Aquisição do retangulo para desenhar o item
  172.   #     index : índice do item
  173.   #--------------------------------------------------------------------------
  174.   def item_rect(index)
  175.     if @cursor_set_all
  176.       rect = Rect.new
  177.       rect.width = item_width * [col_max, item_max].min + spacing
  178.       rect.height = item_height * (item_max.to_f/col_max).ceil
  179.       rect.x = 0
  180.       rect.y = 0
  181.       rect
  182.     else
  183.       akea_tt_item_rect(index)
  184.     end
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # * Aquisição do retangulo para desenhar o item (para texto)
  188.   #     index : índice do item
  189.   #--------------------------------------------------------------------------
  190.   def item_rect_for_text(index)
  191.     rect = akea_tt_item_rect(index)
  192.     rect.x += 4
  193.     rect.width -= 8
  194.     rect
  195.   end
  196. end
  197.  
  198. #==============================================================================
  199. # ** Window_BattleActor
  200. #------------------------------------------------------------------------------
  201. #  Esta janela para seleção de heróis na tela de batalha.
  202. #==============================================================================
  203.  
  204. class Window_BattleActor < Window_BattleStatus
  205. alias :akea_tt_item_rect :item_rect
  206. attr_reader :cursor_set_all
  207.   #--------------------------------------------------------------------------
  208.   # * Ativar a Janela
  209.   #--------------------------------------------------------------------------
  210.   def activate
  211.     @cursor_set_all = false
  212.     super
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # * Selecionar o cursor
  216.   #--------------------------------------------------------------------------
  217.   def set_rect_cursor
  218.     @cursor_set_all = !@cursor_set_all
  219.     update_cursor
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # * Aquisição do retangulo para desenhar o item
  223.   #     index : índice do item
  224.   #--------------------------------------------------------------------------
  225.   def item_rect(index)
  226.     if @cursor_set_all
  227.       rect = Rect.new
  228.       rect.width = item_width * col_max + spacing
  229.       rect.height = item_height * (item_max.to_f/col_max).ceil
  230.       rect.x = 0
  231.       rect.y = 0
  232.       rect
  233.     else
  234.       akea_tt_item_rect(index)
  235.     end
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # * Aquisição do retangulo para desenhar o item (para texto)
  239.   #     index : índice do item
  240.   #--------------------------------------------------------------------------
  241.   def item_rect_for_text(index)
  242.     rect = akea_tt_item_rect(index)
  243.     rect.x += 4
  244.     rect.width -= 8
  245.     rect
  246.   end
  247. end
  248.  
  249.  
  250. #==============================================================================
  251. # ** Game_Action
  252. #------------------------------------------------------------------------------
  253. #  Esta classe gerencia as ações do combate.
  254. # Esta classe é usada internamente pela classe Game_Battler.
  255. #==============================================================================
  256.  
  257. class Game_Action
  258. alias :akea_tt_initialize :initialize
  259. alias :akea_tt_targets_for_opponents :targets_for_opponents
  260. alias :akea_tt_targets_for_friends :targets_for_friends
  261. attr_accessor   :akea_toggle
  262. attr_accessor :cursor_opposit_set
  263.   #--------------------------------------------------------------------------
  264.   # * Inicialização do objeto
  265.   #--------------------------------------------------------------------------
  266.   def initialize(subject, forcing = false)
  267.     @akea_toggle = false
  268.     @cursor_opposit_set = false
  269.     akea_tt_initialize(subject, forcing = false)
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # * Alvos para inimigos
  273.   #--------------------------------------------------------------------------
  274.   def targets_for_opponents
  275.     return opponents_unit.alive_members if @akea_toggle || (@cursor_opposit_set && !item.for_one?)
  276.     if @cursor_opposit_set && item.for_one?
  277.       num = 1 + (attack? ? subject.atk_times_add.to_i : 0)
  278.       if @target_index < 0
  279.         return [opponents_unit.random_target] * num
  280.       else
  281.         return [opponents_unit.smooth_target(@target_index)] * num
  282.       end
  283.     end
  284.     akea_tt_targets_for_opponents
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # * Alvos para aliados
  288.   #--------------------------------------------------------------------------
  289.   def targets_for_friends
  290.     return friends_unit.alive_members if @akea_toggle || (@cursor_opposit_set && !item.for_one?)
  291.     if @cursor_opposit_set && item.for_one?
  292.       return [friends_unit.smooth_target(@target_index)]
  293.     end
  294.     akea_tt_targets_for_friends
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # * Criação da lista de alvos
  298.   #--------------------------------------------------------------------------
  299.   def make_targets
  300.     return unless item
  301.     if !forcing && subject.confusion?
  302.       [confusion_target]
  303.     elsif item.for_opponent?
  304.       if @cursor_opposit_set
  305.         targets_for_friends
  306.       else
  307.         targets_for_opponents
  308.       end
  309.     elsif item.for_friend?
  310.       if @cursor_opposit_set
  311.         targets_for_opponents
  312.       else
  313.         targets_for_friends
  314.       end
  315.     else
  316.       []
  317.     end
  318.   end
  319. end
  320.  
  321. #==============================================================================
  322. # ** Game_ActionResult
  323. #------------------------------------------------------------------------------
  324. #  Esta classe gerencia os resultados das ações nos combates.
  325. # Esta classe é usada internamente pela classe Game_Battler.
  326. #==============================================================================
  327.  
  328. class Game_ActionResult
  329. alias :akea_tt_make_damage :make_damage
  330.   #--------------------------------------------------------------------------
  331.   # * Criação do dano
  332.   #     value : valor do dano
  333.   #     item  : objeto
  334.   #--------------------------------------------------------------------------
  335.   def make_damage(value, item)
  336.     akea_tt_make_damage(value, item)
  337.   end
  338. end
  339. #==============================================================================
  340. # ** Game_Battler
  341. #------------------------------------------------------------------------------
  342. #  Esta classe gerencia os battlers. Controla a adição de sprites e ações
  343. # dos lutadores durante o combate.
  344. # É usada como a superclasse das classes Game_Enemy e Game_Actor.
  345. #==============================================================================
  346. class Game_Battler < Game_BattlerBase
  347.   #--------------------------------------------------------------------------
  348.   # * Cálculo de dano
  349.   #     user : usuário
  350.   #     item : habilidade/item
  351.   #--------------------------------------------------------------------------
  352.   def make_damage_value(user, item)
  353.     value = item.damage.eval(user, self, $game_variables)
  354.     if user.current_action.akea_toggle
  355.       note = /<toggle_split *(\d+)?>/i
  356.       if  item.note =~ note
  357.         value *= ($1.to_f/$game_troop.alive_members.size)/100.0
  358.       end
  359.     end
  360.     value *= item_element_rate(user, item)
  361.     value *= pdr if item.physical?
  362.     value *= mdr if item.magical?
  363.     value *= rec if item.damage.recover?
  364.     value = apply_critical(value) if @result.critical
  365.     value = apply_variance(value, item.damage.variance)
  366.     value = apply_guard(value)
  367.     @result.make_damage(value.to_i, item)
  368.   end
  369. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement